/**
  * Displays a single Customer model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id = null)
 {
     if (Yii::$app->user->can('createProject') && $id) {
         $model = $this->findModel($id);
     } else {
         $model = Customer::find()->where(['user_id' => \Yii::$app->user->id]);
     }
     return $this->render('view', ['model' => $model]);
 }
 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]);
     }
 }
 /**
  * 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;
 }
Beispiel #5
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;
 }
 /**
  * Lists all Customer models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Customer::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
 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;
 }
 /**
  * Updates an existing ContactMoment 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();
     if ($model->load(Yii::$app->request->post()) && $customer->load(Yii::$app->request->post()) && $this->saveProject($model, $customer)) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'customers' => Customer::find()->all(), 'customer' => $customer]);
     }
 }
				existingContact();
			}
		}
	', View::POS_HEAD);
$this->registerJs('$("document").ready(checkIfUpdating());');
$this->title = Yii::t('project', 'Create Project');
$this->params['breadcrumbs'][] = ['label' => Yii::t('project', 'Projects'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-create">
	<div class="block">
    
    <?php 
$form = ActiveForm::begin();
$projectmanagers = User::getProjectManagers();
$customers = Customer::find()->all();
?>

    <?php 
echo $form->field($model, 'description')->textInput();
?>
    <?php 
echo $form->field($model, 'status')->dropDownList(Project::statusses());
?>
    <?php 
echo $form->field($model, 'projectmanager_id')->dropDownList(ArrayHelper::map($projectmanagers, 'id', 'username'), ['prompt' => Yii::t('project', 'Select a projectmanager')]);
?>
	    
    <div id="existing-user" style="display:none;">
    	<fieldset>
    		<legend><?php 
/* @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>
Beispiel #11
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]);
 }