Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Category $categoryModel, Brand $brandModel, Provider $providerModel)
 {
     $categoryList = $categoryModel->getCategoriesList();
     $brandList = $brandModel->getFullBrandsList();
     $providerList = $providerModel->getProvedrsList();
     return view('filter.index')->with('title', 'Фильтр')->with('categoryList', $categoryList)->with('brandList', $brandList)->with('providerList', $providerList);
 }
Example #2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Category::creating(function ($category) {
         $category->slug = Helper::slugify($category->name);
         return true;
     });
     Category::updating(function ($category) {
         $category->slug = Helper::slugify($category->name);
         return true;
     });
     Provider::creating(function ($provider) {
         $provider->slug = Helper::slugify($provider->name);
         return true;
     });
     Provider::updating(function ($provider) {
         $provider->slug = Helper::slugify($provider->name);
         return true;
     });
     Product::creating(function ($product) {
         $product->slug = Helper::slugify($product->name);
         return true;
     });
     Product::updating(function ($product) {
         $product->slug = Helper::slugify($product->name);
         return true;
     });
 }
 /**
  * Finds the Provider model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Provider the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Provider::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement("SET FOREIGN_KEY_CHECKS = 0");
     Provider::truncate();
     $fileName = '2016-02-25-providers';
     $table_name = 'providers';
     $fullFile = 'database/seeds/main/csv/' . $fileName . '.csv';
     $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE {$table_name} FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n'", addslashes($fullFile));
     DB::connection()->getPdo()->exec($query);
     DB::statement("SET FOREIGN_KEY_CHECKS = 1");
 }
 /**
  * Send User to Oauth URL
  */
 public function connect($provider_name, $redir)
 {
     session(['oauth_redir' => $redir]);
     try {
         $provider = Provider::where('provider_safe_name', '=', $provider_name)->firstOrFail();
     } catch (ModelNotFoundException $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
     return Socialite::driver($provider_name)->redirect();
 }
Example #6
0
 public function loginProvider()
 {
     /** @var Provider $model */
     $model = Provider::find()->where(['email' => $this->username])->one();
     if (!is_null($model) && $model->password == $this->password) {
         return $model;
     } else {
         $this->addError('password', Yii::t('app', 'Incorrect User or Password'));
         return null;
     }
 }
Example #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Provider::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Simple control to load the profile page
  *
  * @return view
  */
 public function load_profile()
 {
     $user = Auth::user();
     $user_providers = User::find($user->id)->providers;
     $data['providers'] = Provider::all();
     $data['user'] = $user;
     foreach ($data['providers'] as $i => $provider) {
         foreach ($user_providers as $j => $my_provider) {
             if ($provider->id == $my_provider->id) {
                 $data['providers'][$i]->owned = TRUE;
             }
         }
     }
     return view('pages.profile', $data);
 }
Example #9
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index($slug)
 {
     $explodeSlug = explode('-', $slug);
     $brandId = explode('.', end($explodeSlug))[0];
     if (!$brandId) {
         return false;
     }
     $obj = new Product();
     $AllparentID = Provider::where('parent_key', $brandId)->get()->toArray();
     $idPr = [];
     if ($AllparentID) {
         foreach ($AllparentID as $val) {
             array_push($idPr, $val['id']);
         }
         $res = Product::whereIn('provider_id', $idPr)->orderBy('id', 'desc');
     } else {
         $res = Product::where('provider_id', $brandId)->orderBy('id', 'desc');
     }
     $res = $this->paging($res, $this->req, false);
     $brandName = Provider::find($brandId);
     $data = ['title' => 'Nhãn hiệu', 'brand_name' => $brandName->name, 'product' => $res, 'total' => $this->total, 'total_page' => $this->total_page];
     return View::make('user/brand', $data);
 }
Example #10
0
<?php

use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\ProductSearch */
/* @var $form yii\widgets\ActiveForm */
$categories = ArrayHelper::map(\app\models\Category::find()->orderBy(['url_code' => SORT_ASC])->all(), 'id', 'name');
$providers = ArrayHelper::map(\app\models\Provider::find()->orderBy(['name' => SORT_ASC])->all(), 'id', 'name');
$hideFilter = empty($model->code) && empty($model->name) && empty($model->active) && empty($model->category_id) && empty($model->provider_id);
?>

<div class="product-search" style="background-color: #f8f8f8;padding: 1px 20px;margin-bottom: 10px;position: relative;">

    <a href="#" style="position: absolute;right: 15px;top:5px;" onclick="$('.filters').toggle();return false;">Show/Hide Filters</a>
    <div class="filters" style="<?php 
echo $hideFilter ? 'display: none;' : '';
?>
">
    <h3>Filter by</h3>

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>

    <div class="row">
        <div class="col-sm-2">
            <?php 
echo $form->field($model, 'code');
?>
Example #11
0
 /**
  * Reads a Provider
  *
  * @param  string  $provider_id
  * @return \App\Models\Provider
  */
 public function get($provider_id)
 {
     return \App\Models\Provider::find($provider_id);
 }
Example #12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Label $labelModel, History $historyModel, Purchase $purchaseModel, Provider $providerController, Brand $brandModel, Category $categoryModel, Product $productModel, $id)
 {
     $product = $productModel->getProduct($id);
     if (!$product) {
         abort(404);
     }
     $purchase = $purchaseModel->getPurchase($id);
     $historyProduct = $historyModel->getProductHistory($id);
     $historyPurchase = $historyModel->getPurchaseHistory($id);
     $historySite = $historyModel->getSiteHistory($id);
     $labels = $labelModel->getLabelsByProductsId([$id]);
     $arLabels = [];
     foreach ($labels as $label) {
         $arLabels[] = $label->label;
     }
     $strLabels = implode(',', $arLabels);
     if (!empty($product->childs)) {
         $product->childs = unserialize($product->childs);
     }
     $categories_list = $categoryModel->getFullCategoriesList();
     $brands_list = $brandModel->getFullBrandsList();
     $provider_list = $providerController->getProvedrsList();
     return view('products.show')->with('title', $product->category_name . ' ' . $product->name)->with('product', $product)->with('purchase', $purchase)->with('categories_list', $categories_list)->with('brands_list', $brands_list)->with('provider_list', $provider_list)->with('history_product', $historyProduct)->with('history_purchase', $historyPurchase)->with('history_site', $historySite)->with('labels', $strLabels);
 }
Example #13
0
 public static function GenerateFake($faker)
 {
     return ['uid' => $faker->uuid, 'access_token' => $faker->swiftBicNumber, 'user_id' => $faker->numberBetween($min = 1, $max = User::count()), 'provider_id' => $faker->numberBetween($min = 1, $max = Provider::count())];
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id, Category $categoryModel, Provider $providerModel)
 {
     if (!right('EditCategory')) {
         abort(404);
     }
     $category = $categoryModel->getCategory($id);
     if (count($category) < 1) {
         abort(404);
     }
     $fullList = $categoryModel->getFullCategoriesList();
     $providers_list = $providerModel->getExistInCategoryProvedrsList($id);
     $chain = $categoryModel->getParents($id);
     return view('category.edit')->with('title', 'Редактирование категории ' . $category->name)->with('category', $category)->with('chain', $chain)->with('fullList', $fullList)->with('provider_list', $providers_list)->with('current_id', $id);
 }
Example #15
0
 public function update(ProviderRequest $request, $id)
 {
     $inputs = $request->input();
     $file = $request->file('picture');
     $destinationPath = base_path() . '/public/image/provider/';
     if ($request->hasFile('picture')) {
         $name = time() . $file->getClientOriginalName();
         $file->move($destinationPath, $name);
         $inputs['picture'] = $name;
     }
     $inputs['updated_by'] = Auth::user()->id;
     $inputs['updated_at'] = time();
     unset($inputs['_method']);
     unset($inputs['_token']);
     Provider::where(['id' => $id])->update($inputs);
     Session::flash('flash_message', 'Product & Service Provider updated successfully');
     return redirect('providers');
 }
Example #16
0
 /**
  * Create Facebook profile with the given data.
  *
  * @param  $id
  * @param  $access_token
  * @param  $user_id
  * @return bool
  */
 public function createFromFacebook($id, $access_token, $user_id)
 {
     return $this->create(['uid' => $id, 'access_token' => $access_token, 'user_id' => $user_id, 'provider_id' => Provider::findFirst("name = 'facebook'")->id]);
 }
<?php

/** @var $model Order */
/** @var $provider Order */
use app\models\Order;
use app\models\Provider;
use yii\helpers\Url;
$orderShipping = $model->orderShipping;
$destinationAccount = $orderShipping->getDestinationAccount();
$url_destination = Url::base(true) . '/destinatario/';
$instructions = [];
foreach ($providers as $provID) {
    if (!is_null($provider = Provider::findOne($provID))) {
        if (!empty($provider->destination_instructions)) {
            $instructions[] = $provider->destination_instructions;
        }
    }
}
echo $this->render('_top');
?>

    <h2>Confirmaci&oacute;n de Compra</h2>

    <table class="info">
        <tr>
            <th nowrap="nowrap"><?php 
echo Yii::t('app', 'Order #');
?>
</th>
            <td><?php 
echo $model->id;
Example #18
0
 public function nameMustBeUnique(FunctionalTester $I)
 {
     $this->model->name = Provider::findFirst()->name;
     $I->assertFalse($this->model->save());
 }
Example #19
0
 private function getProviderShowInIndex()
 {
     $ListProvider = Provider::where('active', 1)->where('parent_key', 0)->with(['Child' => function ($query) {
         return $query->orderBy('ordinal', 'ASC');
     }])->orderBy('ordinal', 'ASC');
     return $ListProvider->get();
 }
Example #20
0
 public function getProviders()
 {
     $providers = Provider::where('status', 1)->lists('name', 'id');
     $dropdown = view('ajaxView.providerDropDown')->with('providers', $providers)->render();
     return response()->json($dropdown);
 }
Example #21
0
    echo Yii::t('app', 'Message');
    ?>
:</span>
        <span><?php 
    echo $model->message;
    ?>
</span>
    </p>
<?php 
}
?>

<?php 
foreach ($model->getProductsByProviders() as $provId => $items) {
    /** @var Provider $provider */
    $provider = Provider::findOne($provId);
    ?>

    <div style="padding: 2px 5px 12px 5px;border-bottom: 1px dotted #cccccc;">

        <?php 
    echo !is_null($provider) && !empty($provider->name) ? Html::tag('h3', $provider->name, []) : '';
    ?>

        <table class="table table-bordered">
            <thead>
            <tr>
                <th><?php 
    echo Yii::t('app', 'Items');
    ?>
</th>
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(History $historyModel, Provider $providerModel, Request $request, $id)
 {
     if (isset($_POST['update_provider'])) {
         if (!right('EditProvider')) {
             abort(404);
         }
         if (strlen($request->input('name')) > 0) {
             $data = array('name' => $request->input('name'), 'note' => $request->input('note'), 'updated_at' => date('Y-m-d H:i:s'), 'user_id' => Auth::User()->id);
             $providerModel->updateProvider($id, $data);
             $historyModel->saveHistory('update_provider', $request->input('name'));
             Session::flash('message', GetMessages("SUCCESS_UPDATE_PROVIDER"));
             return redirect()->route('provider.index');
         } else {
             Session::flash('message', GetMessages("ERROR_EMPTY_NAME_PROVIDER"));
             return redirect($_SERVER['HTTP_REFERER']);
         }
     }
     if (isset($_POST['status_provider'])) {
         if (!right('EditProvider')) {
             abort(404);
         }
         $providerModel->changeStatus($id, $request->input('status'));
         $historyModel->saveHistory('status_provider', $id, $request->input('status'));
         Session::flash('message', GetMessages("SUCCESS_CHANGE_STATUS_PROVIDER"));
         return redirect($_SERVER['HTTP_REFERER']);
     }
 }
Example #23
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProvider()
 {
     return $this->hasOne(Provider::className(), ['id' => 'provider_id']);
 }
Example #24
0
 public function saveHistory($action, $object = null, $dop = null)
 {
     switch ($action) {
         case 'create_category':
             $message = "Создал категорию [" . $object . "]";
             $label = 'Категории';
             $colorLabel = 'label label-success';
             break;
         case 'rename_category':
             $message = "Переименовал категорию [" . $object . "]";
             $label = 'Категории';
             $colorLabel = 'label label-success';
             break;
         case 'move_category':
             $categoryModel = new Category();
             $category = $categoryModel->getCategory($object, array('name'));
             $message = "Переименовал категорию [" . $category->name . "]";
             $label = 'Категории';
             $colorLabel = 'label label-success';
             break;
         case 'status_category':
             $categoryModel = new Category();
             $category = $categoryModel->getCategory($object, array('name'));
             if ($dop) {
                 $message = "Включил категорию [" . $category->name . "]";
             } else {
                 $message = "Отключил категорию [" . $category->name . "]";
             }
             $label = 'Категории';
             $colorLabel = 'label label-success';
             break;
         case 'create_user':
             $message = "Создал пользователя [" . $object . "]";
             $label = 'Пользователи';
             $colorLabel = 'label';
             break;
         case 'update_user':
             $message = "Отредактировал пользователя(ей) [" . $object . "]";
             $label = 'Пользователи';
             $colorLabel = 'label';
             break;
         case 'status_user':
             $userModel = new User();
             $user = $userModel->getUser($object, array('showname'));
             if ($dop) {
                 $message = "Включил пользователя [" . $user->showname . "]";
             } else {
                 $message = "Отключил пользователя [" . $user->showname . "]";
             }
             $label = 'Пользователи';
             $colorLabel = 'label';
             break;
         case 'create_currency':
             $message = "Создал новую валюту [" . $object . "]";
             $label = 'Валюты';
             $colorLabel = 'label label-warning';
             break;
         case 'delete_currency':
             $currencyModel = new Currency();
             $currency = $currencyModel->getNameCurrencyById($object);
             $message = "Удалил валюту [" . $currency . "]";
             $label = 'Валюты';
             $colorLabel = 'label label-warning';
             break;
         case 'update_rate':
             $currencyModel = new Currency();
             $currency = $currencyModel->getNameCurrencyById($object['currency_id']);
             $message = "Установил курс [" . $currency . " = " . $object['rate'] . "]";
             $label = 'Валюты';
             $colorLabel = 'label label-warning';
             break;
         case 'auto_update_currency':
             $this->insert(array('label' => "Валюты", 'color_label' => 'label label-warning', 'action' => "Обновлены курсы валют по ЦБ", 'user_id' => $object, 'created_at' => date('Y-m-d H:i:s')));
             return true;
             break;
         case 'create_note':
             $message = "Создал публичную заметку";
             $label = 'Заметки';
             $colorLabel = 'label';
             break;
         case 'update_products':
             $product = array();
             foreach ($object as $key => $elem) {
                 $product[] = "<a class='h_def' href='/product/" . $key . "'>" . $key . "</a>";
             }
             $message = "Отредактировал товар(ы) [" . implode(', ', $product) . "]";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
         case 'import':
             $text = '';
             if (isset($object['update_prod'])) {
                 $text .= "[" . plural_form($object['update_prod'], 'обновлен', false) . ' ' . plural_form($object['update_prod'], 'товар') . "] ";
             }
             if (isset($object['add_prod'])) {
                 $text .= "[" . plural_form($object['add_prod'], 'добавлен', false) . ' ' . plural_form($object['add_prod'], 'товар') . "] ";
             }
             if (isset($object['add_to_GK'])) {
                 $text .= "[на ГК " . plural_form($object['add_to_GK'], 'добавлен', false) . ' ' . plural_form($object['add_to_GK'], 'товар') . "] ";
             }
             if (isset($object['add_to_TV'])) {
                 $text .= "[на ТВ " . plural_form($object['add_to_TV'], 'добавлен', false) . ' ' . plural_form($object['add_to_TV'], 'товар') . "] ";
             }
             if (isset($object['add_to_MK'])) {
                 $text .= "[на МК " . plural_form($object['add_to_MK'], 'добавлен', false) . ' ' . plural_form($object['add_to_MK'], 'товар') . "] ";
             }
             if (isset($object['update_purch'])) {
                 $text .= "[" . plural_form($object['update_purch'], 'обновлен', false) . ' ' . plural_form($object['update_purch'], 'условие') . "] ";
             }
             if (isset($object['add_purch'])) {
                 $text .= "[" . plural_form($object['add_purch'], 'добавлен', false) . ' ' . plural_form($object['add_purch'], 'условие') . "] ";
             }
             $message = "Импорт. " . $text;
             $label = 'Импорт';
             $colorLabel = 'label label-warning';
             break;
         case 'create_product':
             $message = "Добавил товар [<a class='h_def' href='/product/" . $object . "'>" . $object . "</a>]";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
             /*case 'create_product_imp':
               $message = "Добавил товар [<a class='h_def' href='/product/" . $object . "'>". $object . "</a>]";
               $label = 'Товары и цены';
               $colorLabel = 'label label-primary';
               break;*/
         /*case 'create_product_imp':
           $message = "Добавил товар [<a class='h_def' href='/product/" . $object . "'>". $object . "</a>]";
           $label = 'Товары и цены';
           $colorLabel = 'label label-primary';
           break;*/
         case 'add_to_site':
             $message = "Добавил товар [<a class='h_def' href='/product/" . $object . "'>" . $object . "</a>] на сайт [" . $dop . "]";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
         case 'add_to_site_imp':
             $message = "Добавил товар [<a class='h_def' href='/product/" . $object . "'>" . $object . "</a>] на сайт [" . $dop . "] через импорт";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
         case 'update_purchase':
             $product = array();
             foreach ($object as $elem) {
                 $product[] = "<a class='h_def' href='/product/" . $elem['product_id'] . "'>" . $elem['product_id'] . "</a>";
             }
             $message = "Отредактировал товар(ы) [" . implode(', ', $product) . "]";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
         case 'add_purchase':
             $message = "Добавил условия для товара [<a class='h_def' href='/product/" . $object . "'>" . $object . "</a>]";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
         case 'del_purchase':
             $message = "Удалил условие товара [<a class='h_def' href='/product/" . $object . "'>" . $object . "</a>]";
             $label = 'Товары и цены';
             $colorLabel = 'label label-primary';
             break;
         case 'create_brand':
             $message = "Создал производителя [" . $object . "]";
             $label = 'Производители';
             $colorLabel = 'label label-success';
             break;
         case 'rename_brand':
             $message = "Переименовал производителя [" . $object . "]";
             $label = 'Производители';
             $colorLabel = 'label label-success';
             break;
         case 'status_brand':
             $brandModel = new Brand();
             $brand = $brandModel->getBrand($object, array('name'));
             if ($dop) {
                 $message = "Включил производителя [" . $brand->name . "]";
             } else {
                 $message = "Отключил производителя [" . $brand->name . "]";
             }
             $label = 'Производители';
             $colorLabel = 'label label-success';
             break;
         case 'create_provider':
             $message = "Создал поставщика [" . $object . "]";
             $label = 'Поставщики';
             $colorLabel = 'label label-success';
             break;
         case 'update_provider':
             $message = "Отредактировал поставщика [" . $object . "]";
             $label = 'Поставщики';
             $colorLabel = 'label label-success';
             break;
         case 'status_provider':
             $provoderModel = new Provider();
             $provider = $provoderModel->getProvider($object, array('name'));
             if ($dop) {
                 $message = "Включил поставщика [" . $provider->name . "]";
             } else {
                 $message = "Отключил поставщика [" . $provider->name . "]";
             }
             $label = 'Поставщики';
             $colorLabel = 'label label-success';
             break;
         default:
             $label = 'Что-то пошло не так';
             $colorLabel = 'label label-danger';
             $message = 'Что-то пошло не так';
     }
     $this->insert(array('label' => $label, 'color_label' => $colorLabel, 'action' => $message, 'user_id' => Auth::User()->id, 'created_at' => date('Y-m-d H:i:s')));
 }
 public function saveProviders($from = 1)
 {
     $from = 34270;
     $step = 100;
     $max_steps = 100;
     $walk = true;
     while ($walk) {
         // [2] make the call to the API
         $data = ['rangoInicio' => $from, 'rangoFinal' => $from + $step];
         // [2.1] the CURL stuff
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_URL, $this->apiProveedores2);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
         $result = curl_exec($ch);
         $con = json_decode($result);
         foreach ($con as $p) {
             $provider = Provider::firstOrCreate(['rfc' => $p->rfc, 'name' => $p->name]);
             $provider->total = $p->total;
             // address
             $provider->street = $p->address->streetAddress;
             $provider->locality = $p->address->locality;
             $provider->region = $p->address->region;
             $provider->zip = $p->address->postalCode;
             $provider->country = $p->address->countryName;
             // contactPoint
             $provider->contact_name = $p->contactPoint->name;
             $provider->email = $p->contactPoint->email;
             $provider->phone = $p->contactPoint->telephone;
             $provider->fax = $p->contactPoint->faxNumber;
             $provider->url = $p->contactPoint->url;
             $provider->update();
         }
         echo $from . "<br>";
         $max_steps--;
         $from += $step;
         if ($max_steps < 1) {
             $walk = false;
         }
     }
 }
Example #26
0
 public function postDelbyid(Request $request)
 {
     $id = $request->input('id');
     if (!$id) {
         $this->error = false;
         $this->error_message = 'Error , please submit again !';
         goto next;
     }
     try {
         $obj = Provider::find($id);
         $obj->delete();
         $this->message = 'Xóa nhà cung cấp thành công !';
     } catch (Exception $e) {
         $this->error = false;
         $this->error_message = $e->getMessage();
     }
     next:
     return $this->ResponseData();
 }