/**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Form::macro('textField', function ($name, $label = null, $value = null, $attributes = array()) {
         $element = Form::text($name, $value, fieldAttributes($name, $attributes));
         return fieldWrapper($name, $label, $element);
     });
     Form::macro('passwordField', function ($name, $label = null, $attributes = array()) {
         $element = Form::password($name, fieldAttributes($name, $attributes));
         return fieldWrapper($name, $label, $element);
     });
     Form::macro('textareaField', function ($name, $label = null, $value = null, $attributes = array()) {
         $element = Form::textarea($name, $value, fieldAttributes($name, $attributes));
         return fieldWrapper($name, $label, $element);
     });
     Form::macro('selectField', function ($name, $label = null, $options, $value = null, $attributes = array()) {
         $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
         return fieldWrapper($name, $label, $element);
     });
     Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = array()) {
         $attributes = array_merge($attributes, ['multiple' => true]);
         $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
         return fieldWrapper($name, $label, $element);
     });
     Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = array()) {
         $attributes = array_merge(['id' => 'id-field-' . $name], $attributes);
         $out = '<div class="checkbox';
         $out .= fieldError($name) . '">';
         $out .= '<label>';
         $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label;
         $out .= '</div>';
         return $out;
     });
     function fieldWrapper($name, $label, $element)
     {
         $out = '<div class="form-group';
         $out .= fieldError($name) . '">';
         $out .= fieldLabel($name, $label);
         $out .= $element;
         $out .= '</div>';
         return $out;
     }
     function fieldError($field)
     {
         $error = '';
         if ($errors = Session::get('errors')) {
             $error = $errors->first($field) ? ' has-error' : '';
         }
         return $error;
     }
     function fieldLabel($name, $label)
     {
         if (is_null($label)) {
             return '';
         }
         $name = str_replace('[]', '', $name);
         $out = '<label for="id-field-' . $name . '" class="control-label">';
         $out .= $label . '</label>';
         return $out;
     }
     function fieldAttributes($name, $attributes = array())
     {
         $name = str_replace('[]', '', $name);
         return array_merge(['class' => 'form-control', 'id' => 'id-field-' . $name], $attributes);
     }
 }
    return fieldWrapper($name, $label, $element);
});
Form::macro('selectField', function ($name, $label = null, $options, $value = null, $attributes = array()) {
    $attributes = $attributes + ['class' => 'selectize'];
    $element = Form::select($name, [null => 'Select One'] + $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = array()) {
    $attributes = array_merge($attributes, ['multiple' => true]);
    $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('booleanField', function ($name, $label = null, $value = null, $attributes = array()) {
    $attributes = $attributes + ['class' => 'selectize'];
    $element = Form::select($name, [null => 'Select One', 1 => 'Enabled', 0 => 'Disabled'], $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = array()) {
    $attributes = array_merge(['id' => 'id-field-' . $name], $attributes);
    $out = '<div class="checkbox';
    $out .= fieldError($name) . '">';
    $out .= '<label>';
    $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label;
    $out .= '</div>';
    return $out;
});
function fieldWrapper($name, $label, $element)
{
    $out = '<div class="form-group';
    $out .= fieldError($name) . '">';
    $out .= fieldLabel($name, $label);
Example #3
0
 }
 if ($introduced) {
     $htmlFormContents = $htmlFormContents . fieldWrapper('Customer Introduced From:', $introduced . ($introducedBy != NULL ? ', ' . $introducedBy : ''));
 }
 if ($existingSupplier) {
     $htmlFormContents = $htmlFormContents . fieldWrapper('Have Existing Water Supplier', $existingSupplier);
 }
 if (strcmp($existingSupplier, "yes") == 0) {
     if ($supplier) {
         $htmlFormContents = $htmlFormContents . fieldWrapper('Existing Supplier Name', $supplier);
     }
     if ($system) {
         $htmlFormContents = $htmlFormContents . fieldWrapper('Existing Water System', $system . ($systemOther != NULL ? ', ' . $systemOther : ''));
     }
     if ($reason) {
         $htmlFormContents = $htmlFormContents . fieldWrapper('reason', $reason);
     }
 }
 $htmlMessage = file_get_contents('emailtemplate/jantzen.html');
 $htmlMessage = str_replace('<!--%htmlFormContents%-->', $htmlFormContents, $htmlMessage);
 if ($use == "household") {
     $mail->Subject = 'New Customer Enquiry from ' . $name;
 } else {
     $mail->Subject = 'New Customer Enquiry from ' . $companyName;
 }
 $mail->addAddress($emailToAdmin, 'Jantzen');
 $mail->addReplyTo($email, 'New Customer');
 $htmlEmailIntro = '<h3 style="color: black;">Enquiry from new customer:</h3>';
 $mail->MsgHTML(str_replace('<!--%htmlEmailIntro%-->', $htmlEmailIntro, $htmlMessage));
 if (!$mail->send()) {
     //   echo 'Mailer Error: ' . $mail->ErrorInfo;