public function actionIndex()
    {
        if(Auction::$app->user->isGuest){
            Auction::warning('Guest User :: Redirecting to Login Page');
            $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('site/login'));
        }
        else {
            switch (Auction::$app->session->get('user.role')) {
                case DatabaseHelper::ADMIN :
                    Auction::info('Redirecting to Admin Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('admin'));
                    break;

                case DatabaseHelper::DEALER :
                    Auction::info('Redirecting to Dealer Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('dealer/profile'));
                    break;

                case DatabaseHelper::COMPANY_USER :
                    Auction::info('Redirecting to Company User Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('company/profile'));
                    break;

                case DatabaseHelper::COMPANY_ADMIN :
                    Auction::info('Redirecting to Company Admin Module');
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('company/info'));
                    break;

                default :
                    $this->redirect(Auction::$app->urlManager->createAbsoluteUrl('site/login'));
                    Auction::warningLog('Logging Out due to Unknown Role Created On Server',['role' => Auction::userRole()]);
            }
        }
    }
    public function actionView($id)
    {
        $model = Companies::find()->with([
            'dealerCompanies' => function ($query) use ($id){
                $query->joinWith([
                    'dealerCompanyPreferences' => function ($query) {
                        $query->joinWith([
                            'brand0',
                            'category0'
                        ]);
                    }
                ])->where([
                    'dealer_company.company' => $id,
                    'dealer_company.dealer' => Auction::dealer()
                ]);
            }
        ])->where([
            'id' => $id
        ])->one();

        if($model === null){
            Auction::error('There is no Company with Company Id '.$id);
            throw new HttpException(404, 'No Company Found');
        }

        return $this->render('view', [
            'model' => $model,
        ]);
    }
    public static function MessageTemplate($name){
        $message = MessageTemplate::find('name=:name',[':name' => $name])->one();

        if($message){
            return $message->template;
        }else{
            Auction::error('There is no '. $name .' in database create it admin');
            throw new HttpException(400 ,'No '. $name .' Found Create it');
        }
    }
    /**
     * Displays a single Dealers model.
     * @param integer $id
     * @return mixed
     */
    public function actionView($id)
    {
        $_model = Dealers::find()
                    ->with(['user0'])
                    ->where('id=:id',[':id' => $id])
                    ->one();

        if($_model === null){
            Auction::infoLog('No Dealer Found' , ['id' => $id]);
            throw new NotFoundHttpException('No Dealer Found');
        }
        return $this->render('view', [
            'model' => $_model
        ]);
    }
Esempio n. 5
0
    /**
     * Sends an email with a link, for resetting the password.
     *
     * @return boolean whether the email was send
     */
    public function sendEmail()
    {
        /* @var $user  from User validator user variable */

        $user = $this->validators[2]->user;
        Auction::info('User is ready to sent a new Token');

        switch ($this->via){
            case 'email' :
                ForgotPasswordHistory::model()->generateOtp($user);
                break;

            case 'sms':
                OptHistory::model()->generateOtp($user);
        }
        return false;
    }
    protected function dataTables(){

        $allModels =  (new Query())->select(
            '('.(new Query())->select('count(*)')->from(Auctions::tableName())->createCommand()->rawSql.') as auctions,'.
            '('.(new Query())->select('count(*)')->from(Dealers::tableName())->createCommand()->rawSql.') as dealers,'.
            '('.(new Query())->select('count(*)')->from(Companies::tableName())->createCommand()->rawSql.') as companies,'.
            '('.(new Query())->select('count(*)')->from(Brands::tableName())->createCommand()->rawSql.') as brands,'.
            '('.(new Query())->select('count(*)')->from(Categories::tableName())->createCommand()->rawSql.') as categories'
        )->one();

        $_message = Auction::loggerMessageFormat('Admin Dashboard Created With :: ',$allModels);
        Auction::info($_message);

        return new ArrayDataProvider([
            'allModels' => $allModels,
            'pagination' => false
        ]);

    }
    protected function loadProfile(){
        $model = Dealers::find()->joinWith([
            'user0',
            'dealerPreferences' => function($query){
                $query->with([
                    'category0',
                    'brand0'
                ]);
            }
        ])->where([
            'dealers.id' => Auction::$app->session->get('user.dealer', 0)
        ])->one();

        if($model === null){
            Auction::error('No Valid Dealer Found with userid '.Auction::$app->user->id);
            throw new HttpException(404, 'No user found');
        }

        return $model;
    }
    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = ProductConfig::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([
            'company' => Auction::company(),
        ]);

        return $dataProvider;
    }
    /**
     * Action to Perform User Logout
     * Will go Home If User is already logout
    */
    public function actionIndex()
    {

        if(Auction::$app->user->isGuest){
            Auction::warning('User Already is Logged Out');
            return $this->goHome();
        }

        Auction::$app->user->logout();

        //Setting Logger @info
        $message = Auction::loggerMessageFormat('User logout SuccessFully' ,[
            'class' => __CLASS__ ,
            'function' => __METHOD__,
            'username' => Auction::$app->session->get('user.name'),
            'role' => Auction::$app->session->get('user.role'),
            'userId' => Auction::$app->user->id
        ]);
        Auction::info($message,Auction::LOGGER_FRONTEND_CATEGORY);

        return $this->goHome();
    }
Esempio n. 10
0
    public function saveLot($request){
        $this->load($request);

        $transaction = Auction::$app->db->beginTransaction();
        try{
            if(!$this->save())
                return false;

            $preferences= new LotPreference();
            $preferences->load($request);

            $preferences->lots = $this->primaryKey;
            if($preferences->save()){
                $transaction->commit();
                return true;
            }

            return false;

        }catch(Exception $ex){
            Auction::error('Lot Not Saved Due to following Errors'.$ex->getMessage());
            $transaction->rollBack();
            return false;
        }

    }
Esempio n. 11
0
    public function updateAuction($request){
        $transaction = Auction::$app->db->beginTransaction();
        try{


        }catch (Exception $ex){
            $transaction->commit();
            Auction::errorLog('Auction Not Updated '.$ex->getMessage(),$request);
            throw new HttpException(500 , 'DataBase Error');
        }
    }
Esempio n. 12
0
            <div class="login-panel panel panel-info" style="margin-top: 20px">
                <div class="panel-heading">
                    <h3 class="panel-title">Add Preferences</h3>
                </div>
                <div class="panel-body">
                    <?php Pjax::begin(['id' => 'create-preferences',  'enablePushState' => false]) ?>
                    <?php $form = ActiveForm::begin([
                        'id' => 'update-preferences',
                        'action' => \yii\helpers\Url::to(['add-preference']),
                        'fieldClass' => 'auction\widgets\ActiveField',
                        'successCssClass' => false,
                        'options'=> ['role' => 'form' , 'data-pjax' => true]]); ?>
                    <fieldset>
                        <div class="form-group input-group">
                            <?= Html::dropDownList('category','',Auction::dropDownList('auction\models\Categories','id','name'),[]) ?>
                            <?= Html::dropDownList('brand','',Auction::dropDownList('auction\models\Brands','id','name'),[]) ?>
                            <span class="input-group-btn">
                        <button class="btn btn-default" type="submit">
                            <i class="fa fa-plus"></i>
                        </button>
                    </span>
                        </div>

                        <?php if($model->dealerPreferences) :?>
                            <?php foreach($model->dealerPreferences as $param):?>

                                <div class="form-group input-group">
                                    <?= Html::activeTextInput($param->category0, 'name',['class' => 'form-control' ,'disabled' => 'disabled']) ?>
                                    <?= Html::activeTextInput($param->brand0, 'name',['class' => 'form-control' ,'disabled' => 'disabled']) ?>
                                    <span class="input-group-btn">
                                         <?= Html::button('<i class="fa fa-minus"></i>',['class' => 'btn btn-default delete-button' ,'id' => $param->primaryKey])?>
Esempio n. 13
0
<?php
NavBar::begin([
    'brandLabel' => '<img alt="" src="/images/logo-reglobe.png">',
    'brandUrl' => '#',
    'renderInnerContainer' => false,
    'options' => [
        'class' => 'navbar navbar-default navbar-static-top',
        'style' => 'margin-bottom: 0',
        'role' => 'navigation',
        'id' => false
    ],
]);

echo Nav::widget([
      'items' => [
          ['label' => '<div class="Partner-logo navbar-brand">Apple Exchange Program </div>', 'url' => Auction::createUrl('site/login')],
      ],
    'encodeLabels' => false,
    'options' => [
        'class' => 'nav navbar-top-links navbar-right',
    ]
  ]);

NavBar::end();
?>

<div class="container">
    <?= $content?>
</div>
<?php $this->endBody() ?>
</body>
Esempio n. 14
0
    public function BrandList(){
        if($this->_brandList == null){
            $this->_brandList = Auction::dropDownList('auction\models\Brands' , 'id' ,'name');
        }

        return $this->_brandList;
    }
Esempio n. 15
0
    <?php Pjax::begin(['id' => 'brand-form','enablePushState' => false, 'timeout' => false])?>

    <?php $form = ActiveForm::begin([
        'id' => 'create-brand',
        //'action' => Url::to(['brand/create']),
        'options' => [
            'data-pjax' => 1,
        ],
        'enableClientValidation' => false

    ]); ?>


    <?= $form->field($model, 'name')->textInput() ?>

    <?= $form->field($model, 'cat_id')->dropDownList(Auction::dropDownList('auction\models\Categories', 'id', 'name')) ?>

    <?= $form->field($model, 'brand_id')->dropDownList(Auction::dropDownList('auction\models\Brands', 'id', 'name')) ?>

    <?= $form->field($model, 'company')->hiddenInput(['value' => Auction::company()])->label(false) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => ($model->isNewRecord) ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>
    <?php Pjax::end();?>

</div>

Esempio n. 16
0
    /**
     * @param $model
     * @return null|Mixed saved model primary key by setting it's attributes Validation to false
     */
    private function saveModel($model){
        $model->setAttributes($this->getAttributes(),false);

        if($model->save(false)){
            Auction::infoLog('Saving '. $model->className(), $model->getAttributes());
            return $model->primaryKey;
        }
        else {
            return null;
        }
    }
    public function afterSave(){
        $_model = new AuctionEmails();
        $_model->message = strtr(MessageTemplate::MessageTemplate(DatabaseHelper::DEALER_REGISTRATION_TEMPLATE),['{name}' => $this->name]);
        $_model->to = $this->email;
        $_model->subject = 'Auction :: Company Registration';
        $_model->from = 'Auction';
        $_model->status = DatabaseHelper::SEND_MAIL;

        if($_model->save()){
            Auction::info('Company Registration Email registered');
        }
        else {
            $message= Auction::loggerMessageFormat('Email is not send to user due to following errors',$_model->getErrors());
            Auction::error($message);
        }
    }
Esempio n. 18
0
    public function UploadDirectory(){

        if($this->_uploadDirectory === null){
            $this->_uploadDirectory = Auction::getAlias('@webroot').'/uploads/dealers/';
        }

        return $this->_uploadDirectory;
    }
Esempio n. 19
0
    public function init()
    {

        $_role = Auction::userRole();

        if ($_role == DatabaseHelper::COMPANY_ADMIN) {

            $this->items = [
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Dashboard', 'url' => Auction::createUrl('company/info')],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Auctions<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Auctions', 'url' => Auction::createUrl('company/auction')],
                        ['label' => '<i class="fa  fa-github-square fa-fw"></i>Add Auction', 'url' => Auction::createUrl('company/auction/create')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Users<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Company Users', 'url' => Auction::createUrl('company/user')],
                        ['label' => '<i class="fa  fa-github-square fa-fw"></i>Dealers', 'url' => Auction::createUrl('company/dealer')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Auction Lots<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Lots', 'url' => Auction::createUrl('company/lots')],
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Add Products In Lot', 'url' => Auction::createUrl('company/lot-product')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Products<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>List Products', 'url' => Auction::createUrl('company/product')],
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Upload CSV', 'url' => Auction::createUrl('company/upload-csv')],
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Create Product Cofig', 'url' => Auction::createUrl('company/product-config')],
                    ],
                ],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Setting<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Update Info', 'url' => Auction::createUrl('company/edit')],
                    ],
                ],
            ];
        } elseif ($_role == DatabaseHelper::DEALER) {

            $this->items = [
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Dashboard', 'url' => Auction::createUrl('dealer/profile')],
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Auctions', 'url' => Auction::createUrl('dealer/auction')],
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Companies', 'url' => Auction::createUrl('dealer/company')],
                ['label' => '<i class="fa fa-dashboard fa-fw"></i>Payment', 'url' => Auction::createUrl('dealer/payment')],
                [
                    'template' => '<a class="active" href="#"><i class="fa fa-wrench fa-fw"></i>Setting<span class="fa arrow"></span></a>',
                    'items'    => [
                        ['label' => '<i class="fa fa-play-circle-o fa-fw"></i>Update Info', 'url' => Auction::createUrl('dealer/edit-profile')],
                    ],
                ],
            ];
        }

       $this->items[] = ['label' => '<i class="fa fa-sign-out fa-fw"></i>Sign Out', 'url' => Auction::createUrl('site/logout')];

        parent::init();
    }
Esempio n. 20
0
    <?= $form->field($model, 'amount')->textInput() ?>

    <?= $form->field($model, 'status')->dropDownList(DatabaseHelper::Status()) ?>

    <?= $form->field($model, 'priority')->textInput() ?>

    <?= $form->field($model, 'security')->textInput() ?>

    <?= $form->field($model, 'is_percent')->textInput() ?>

    <?= $form->field($model, 'max_bid')->textInput() ?>

    <?= $form->field($model, 'cooling_prd')->textInput() ?>

    <?= $form->field($model, 'last_min_extd')->textInput() ?>

    <?= $form->field($model, 'max_extd')->textInput() ?>

    <?= $form->field($model, 'category')->dropDownList(\auction\components\Auction::dropDownList('auction\models\Categories' , 'id' ,'name')) ?>

    <?= $form->field($model, 'brand')->dropDownList(\auction\components\Auction::dropDownList('auction\models\Brands' ,'id' , 'name')) ?>

    <div class="form-group">
        <?= Html::submitButton('Create' , ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
Esempio n. 21
0
                'options' => [
                    'class' => 'form-control',
                    'data-id' => '',
                    'placeholder' => 'Search..'
                ]
            ]); ?>
            <span class="input-group-btn">
            <?= Html::submitButton('<i class="fa fa-search"></i>', [
                'id' => 'company-id',
                'class' => 'btn btn-primary',
                'onClick' => new JsExpression('
                var id = $("#name_search").attr("data-id");
                if(id == ""){
                    return false;
                }else{
                    window.location.href = "'. Auction::createUrl('dealer/company/view') .'?id="+id;
                }
                ')
            ]) ?>
            </span>
        </div>
    </div>
</div>

<div class="row">
    <?= ListView::widget([
        'dataProvider' => $dataProvider,
        'itemView' => '_info_panel',
        'emptyText' => '',
        'summary' => false
    ])
Esempio n. 22
0
                'options' => [
                    'class' => 'form-control',
                    'data-id' => '',
                    'placeholder' => 'Search..'
                ]
            ]); ?>
            <span class="input-group-btn">
            <?= Html::submitButton('<i class="fa fa-search"></i>', [
                'id' => 'company-id',
                'class' => 'btn btn-primary',
                'onClick' => new JsExpression('
                var id = $("#name_search").attr("data-id");
                if(id == ""){
                    return false;
                }else{
                    window.location.href = "'. Auction::createUrl('dealer/auction/view') .'&id="+id;
                }
                ')
            ]) ?>
            </span>
        </div>
    </div>
</div>

<div class="row">
    <?php Pjax::begin(['id' => 'pjax-gridview', 'timeout' => false, 'enablePushState' => false]) ?>
    <?= ListView::widget([
        'dataProvider' => $dataProvider,
        'itemView' => '_info_panel',
        'emptyText' => '',
        'summary' => false
Esempio n. 23
0
    public function afterDelete(){

        Auction::warningLog('Model :: ' . self::className() . ' Has Been Deleted ', $this->getAttributes());
        return parent::afterDelete();
    }
Esempio n. 24
0
<?php
/**
 * Created by PhpStorm.
 * User: reglobbe
 * Date: 1/9/15
 * Time: 5:20 PM
 */
use auction\components\Auction;
?>

<div class="error-page">
    <img src="<?= Auction::$app->request->baseUrl?>/images/500-error.jpg" alt="" />
    <h1>Oops, Something went wrong</h1>
    <p>The page you are looking for can’t be found.<br/>
        Go home by <a href="<?php echo Auction::createUrl('site/index')?>">clicking here!</a></p>
</div>
Esempio n. 25
0
    public function addPreference($post){
        $this->brand = ArrayHelper::getValue($post , 'brand');
        $this->category = ArrayHelper::getValue($post ,'category');
        $this->dealer = Auction::dealer();

        if($this->save()){
            return true;
        }else {
            throw new InvalidValueException('Already Exist');
        }
    }
Esempio n. 26
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use auction\models\Auctions;
use yii\widgets\Pjax;
use auction\components\Auction;

/* @var $this yii\web\View */
/* @var $model auction\models\Lots */
/* @var $form yii\widgets\ActiveForm */
?>
<?php Pjax::begin(['id' => 'brand-form','enablePushState' => false, 'timeout' => false])?>

<?php $form = ActiveForm::begin([
    'id' => 'create-brand',
    'action' => Auction::createUrl('company/lots/create'),
    'fieldClass' => 'auction\widgets\ActiveField',
    'options' => [
        'data-pjax' => 1,
    ],
]); ?>

<fieldset>

    <?= $form->field($model, 'name')->textInput() ?>

    <?= $form->field($model, 'auction')->dropDownList(ArrayHelper::map(Auctions::find()->all(),'id','name'),['class' => 'form-control']) ?>

    <?= $form->field($model, 'condition')->textInput() ?>

    <?= $form->field($model, 'is_quantity')->textInput() ?>
Esempio n. 27
0
    /**
     * @param $params
     *
     * Search Auction of company using session value of user.company
     *
     * @return ActiveDataProvider
     */
    public function companyAuction($params){
        $dataProvider= $this->search($params);

        $dataProvider->query->andWhere([
            'companies.id' => Auction::company()
        ]);

        return $dataProvider;
    }
Esempio n. 28
0
                                    ])?>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <h4 class="panel-title">
                                <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">Brand Image</a>
                            </h4>
                        </div>
                        <div id="collapseTwo" class="panel-collapse collapse">
                            <div class="panel-body">
                                <address>
                                    <?= Auction::showImage('brand' , $model->image) ?>
                                </address>
                            </div>

                        </div>
                    </div>
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <h4 class="panel-title">
                                <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">Brand Description</a>
                            </h4>
                        </div>
                        <div id="collapseThree" class="panel-collapse collapse">
                            <div class="panel-body">
                                <address>
                                    <?= Html::encode($model->description) ?>
Esempio n. 29
0
    <?php

    $common_attribute=['name','address'];
    if($model->dealers !== null){
        $attributes=['contact','city'];
        $attributes[] =[
            'label' => 'Profile Pic',
            'format' => 'html',
            'value' => Auction::showImage('dealer' , $model->profile_pic)
        ];
        $detailView=$model->dealers;
    }
    elseif($model->company !== null){
        $attributes=['domain','contact','description'];
        $attributes[] =[
            'label' => 'Profile Picture',
            'format' => 'html',
            'value' => Auction::showImage('company' , $model->company->logo_image)
        ];
        $detailView=$model->company;
    }

    ?>

    <?= DetailView::widget([
        'model' => $detailView,
        'attributes' => ArrayHelper::merge($common_attribute,$attributes)
    ]); ?>
</div>
Esempio n. 30
-1
    protected function renderFilterCellContent()
    {
        //Getting Model Object From Class

        $model = Auction::createObject($this->modelClass);
        return Html::activeDropDownList($this->grid->filterModel,$this->filterAttribute,ArrayHelper::map($model->find()->distinct()->all() , 'id' , $this->modelAttribute),['class' => 'form-control','prompt' => '-------']);
    }