/**
  * 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->email;
         $user->email = $this->email;
         $user->status = User::STATUS_AWAITING_REQUEST;
         if ($user->save(false)) {
             $customer = new Customer();
             $customer->name = $this->company_name;
             $customer->location = $this->location;
             $customer->address = $this->address;
             $customer->zip_code = $this->zip_code;
             $customer->phone_number = $this->phone_number;
             $customer->website = $this->website;
             $customer->kvk = $this->kvk;
             $customer->btw = $this->btw;
             $customer->email_address = $this->email;
             $customer->description = $this->description;
             $customer->contact_type = $this->contact_type;
             $customer->contact = $this->contact;
             $customer->user_id = $user->id;
             if ($customer->save(false)) {
                 return $user;
             } else {
                 $user->delete();
             }
         }
     }
     return null;
 }
Exemplo n.º 2
0
 public function run()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
     } else {
         $errores = $model->getErrors();
     }
     return $this->render('customerRewards', ['model' => $model]);
 }
Exemplo n.º 3
0
 public function actionCustlist()
 {
     if (Yii::$app->request->isAjax) {
         $data = Yii::$app->request->post();
         $id2 = explode(":", $data['id']);
         $search2 = $id2[0];
         $customer = Customer::find()->where(['id' => $search2])->one();
         return $this->renderPartial('_customer', ['customer' => $customer]);
     }
 }
Exemplo n.º 4
0
 /**
  * Creates a new UserMap model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new UserMap();
     $customers = Customer::find()->all();
     $users = User::find()->all();
     $this->cdata = ArrayHelper::map($customers, 'id', 'customer_name');
     $this->udata = ArrayHelper::map($users, 'id', 'username');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'cdata' => $this->cdata, 'udata' => $this->udata]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customer::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(['customer_id' => $this->customer_id, 'user_id' => $this->user_id, 'contact_type' => $this->contact_type]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'phone_number', $this->phone_number])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'kvk', $this->kvk])->andFilterWhere(['like', 'btw', $this->btw])->andFilterWhere(['like', 'email_address', $this->email_address])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'contact', $this->contact]);
     return $dataProvider;
 }
Exemplo n.º 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customer::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])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'pic', $this->pic])->andFilterWhere(['like', 'mobile', $this->mobile]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCustomer()
 {
     return $this->hasOne(Customer::className(), ['customer_id' => 'customer_id']);
 }
Exemplo n.º 8
0
?>
	                
	                <?php 
echo $form->field($model, 'contact');
?>
	                <?php 
echo $form->field($model, 'address');
?>
	                <?php 
echo $form->field($model, 'zip_code');
?>
	                <?php 
echo $form->field($model, 'location');
?>
	    			<?php 
echo $form->field($model, 'contact_type')->dropDownList(Customer::getContactTypes());
?>
	                <?php 
echo $form->field($model, 'phone_number');
?>
	                <?php 
echo $form->field($model, 'website');
?>
	                <?php 
echo $form->field($model, 'kvk');
?>
	                <?php 
echo $form->field($model, 'btw');
?>
	
	
 /**
  * Finds the Customer model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Customer the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Customer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 private function generateProject($uid)
 {
     // Get the Parts
     $steps = $this->getSessionPartsAsArray();
     // Create Project
     $project = new Project();
     $user;
     $customer;
     $previousUser = false;
     if (Yii::$app->session->has('customer')) {
         $customer = Yii::$app->session->get('customer');
         $user = $customer->user;
     } else {
         $user = User::find()->where(['id' => $uid])->one();
         $customer = Customer::find()->where(['user_id' => $user->id])->one();
     }
     // Log in the user temporarily so the project and functionalities get the right creator_id and updater_id
     if (Yii::$app->user->isGuest) {
         Yii::$app->user->login($user);
     } else {
         $previousUser = true;
     }
     $project->client_id = $customer->customer_id;
     $project->status = 0;
     $project->name = $customer->name;
     $project->deleted = 0;
     $project->description = 'Doel van de website: ' . $steps[1]->goal;
     $project->save(false);
     $location = $this->permFileLocation . $project->project_id . '/';
     if (!file_exists($location)) {
         mkdir($location);
     }
     $i = 1;
     $comments = Yii::t('request-project', ' Comments:');
     foreach ($steps as $step) {
         $comment = $this->saveFunctionalities($step, $project->project_id, $uid);
         if (!empty($comment)) {
             $comments .= ' ' . Yii::t('request-project', 'Step');
             $comments .= ' ' . $i . ': ';
             $comments .= $comment;
         }
         $i++;
     }
     if ($comments != Yii::t('request-project', ' Comments:')) {
         $project->description .= $comments;
         $project->save(false);
     }
     // Log the user out
     if (!$previousUser) {
         Yii::$app->user->logout();
     }
     // Notify the admin
     $mail = Yii::$app->mailer->compose(['html' => 'newProjectRegistered-html', 'text' => 'newProjectRegistered-text'], ['customer' => $customer, 'project' => $project]);
     $mail->setFrom('*****@*****.**');
     $mail->setTo('*****@*****.**');
     $mail->setSubject('Er is een nieuw project aangevraagd door ' . $customer->name);
     $mail->send();
     return $project;
 }
Exemplo n.º 11
0
 public function getCustomername()
 {
     return $this->hasOne(\common\models\Customer::className(), ['Cus_id' => 'customer']);
 }
Exemplo n.º 12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCustomers()
 {
     return $this->hasMany(Customer::className(), ['id' => 'customer_id'])->via('reservations');
 }
Exemplo n.º 13
0
/* @var $model common\models\ContactMoment */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="contact-moment-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'moment')->widget(\kartik\datetime\DateTimePicker::classname(), ['pluginOptions' => ['format' => 'yyyy-mm-dd h:ii:00']]);
?>

    <?php 
echo $form->field($model, 'customer_id')->dropDownList(ArrayHelper::map(Customer::find()->all(), 'customer_id', 'email_address'));
?>

    <?php 
echo $form->field($model, 'comment')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'deleted')->checkbox();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
Exemplo n.º 14
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\User;
use common\models\Customer;
/* @var $this yii\web\View */
/* @var $model common\models\Project */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="project-form">

    <?php 
$form = ActiveForm::begin();
$projectmanagers = User::getProjectmanagers();
$customers = Customer::find()->all();
?>
    
    <?php 
echo $form->field($model, 'description')->textInput();
?>

    <?php 
echo $form->field($model, 'client_id')->dropDownList(ArrayHelper::map($customers, 'customer_id', 'name'), ['default' => Yii::t('project', 'Select a client')]);
?>

    <?php 
echo $form->field($model, 'projectmanager_id')->dropDownList(ArrayHelper::map($projectmanagers, 'id', 'username'), ['default' => Yii::t('project', 'Select a projectmanager')]);
?>
    
    <?php 
Exemplo n.º 15
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCustomers()
 {
     return $this->hasMany(Customer::className(), ['id' => 'customer_id'])->viaTable('{{%entp_customer}}', ['entrepreneur_user_id' => 'user_id']);
 }
Exemplo n.º 16
0
</legend>
	    	<?php 
echo Html::button(Yii::t('user', 'Existing user'), ['onClick' => 'js:existingContact()', 'class' => 'btn btn-default']);
?>
	    	
	    	<?php 
echo $form->field($customer, 'name', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
		    <?php 
echo $form->field($customer, 'address', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
		    <?php 
echo $form->field($customer, 'zip_code', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
	    	<?php 
echo $form->field($customer, 'contact_type', ['enableClientValidation' => false])->dropDownList(Customer::getContactTypes());
?>
		    <?php 
echo $form->field($customer, 'location', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
		    <?php 
echo $form->field($customer, 'phone_number', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
		    <?php 
echo $form->field($customer, 'website', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
		    <?php 
echo $form->field($customer, 'kvk', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
?>
		    <?php 
echo $form->field($customer, 'btw', ['enableClientValidation' => false])->textInput(['maxlength' => true]);
 /**
  * Updates an existing Project model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $customer = new Customer();
     $user = new User();
     if ($model->load(Yii::$app->request->post()) && $customer->load(Yii::$app->request->post()) && $this->saveProject($model, $customer)) {
         return $this->redirect(['view', 'id' => $model->project_id]);
     } else {
         return $this->render('update', ['model' => $model, 'customer' => $customer, 'user' => $user]);
     }
 }
Exemplo n.º 18
0
 public function actionIndexWithRelationships()
 {
     // 1. Check what parameter of detail has been passed
     $room_id = Yii::$app->request->get('room_id', null);
     $reservation_id = Yii::$app->request->get('reservation_id', null);
     $customer_id = Yii::$app->request->get('customer_id', null);
     // 2. Fill three models: roomSelected, reservationSelected and customerSelected and
     //    Fill three arrays of models: rooms, reservations and customer;
     $roomSelected = null;
     $reservationSelected = null;
     $customerSelected = null;
     if ($room_id != null) {
         $roomSelected = Room::findOne($room_id);
         $rooms = array($roomSelected);
         $reservations = $roomSelected->reservations;
         $customers = $roomSelected->customers;
     } else {
         if ($reservation_id != null) {
             $reservationSelected = Reservation::findOne($reservation_id);
             $rooms = array($reservationSelected->room);
             $reservations = array($reservationSelected);
             $customers = array($reservationSelected->customer);
         } else {
             if ($customer_id != null) {
                 $customerSelected = Customer::findOne($customer_id);
                 $rooms = $customerSelected->rooms;
                 $reservations = $customerSelected->reservations;
                 $customers = array($customerSelected);
             } else {
                 $rooms = Room::find()->all();
                 $reservations = Reservation::find()->all();
                 $customers = Customer::find()->all();
             }
         }
     }
     return $this->render('index-with-relationships', ['roomSelected' => $roomSelected, 'reservationSelected' => $reservationSelected, 'customerSelected' => $customerSelected, 'rooms' => $rooms, 'reservations' => $reservations, 'customers' => $customers]);
 }