Browse Source

- add send message "Help"
(add data in table QUALITY_NOTICES
and wrote script for send mail - please add php function mail() -
sending not working)

dariusz.andryskowski 7 years ago
parent
commit
077f84b434
2 changed files with 65 additions and 15 deletions
  1. 40 10
      tools/Bocian.php
  2. 25 5
      tools/page-help.view.php

+ 40 - 10
tools/Bocian.php

@@ -8,7 +8,7 @@ Lib::loadClass('Request');
 // index.php?_route=UrlAction_BiAuditRaport  - uruchamia defaultAction
 class RouteTool_Bocian extends RouteToolBase {
 
-public static $helpEmailTo = 'dariusz@yellowgroup.pl';
+public static $helpEmailTo = 'biuro@bialnet.com.pl'; // email na który zostanie wysłane zapytanie z formularza POMOCY
 
 	public static $FIELD_LIST_PRACOWNICY = [
 		'ID',
@@ -89,24 +89,50 @@ public static $helpEmailTo = 'dariusz@yellowgroup.pl';
 			echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
 			Theme::top();
 
+			$messageValidate = array();
+			if( V::get('button_send', 0, $_POST) == 1 ){
 
-
-
-			$responseSendMail = false;
-			if( V::get('button_send', 0, $_POST) != '' ){
-				print V::get('button_send', '1', $_POST); print "|";
 					// fields form
+					$helpName    		= htmlentities(V::get('help_name', 0, $_POST));
 			    $helpEmail    		= htmlentities(V::get('help_email', 0, $_POST));
 			    $helpDescription  = htmlentities(V::get('help_description', 0, $_POST));
 
-
 					if ( empty($helpDescription) && !filter_var($helpEmail, FILTER_VALIDATE_EMAIL)) {
-						throw new Exception("Błąd! Wypełnij wszystkie pola");
+						$messageValidate['error'] = 1;
 					}
 
+					// data for create insert in DB
+					$idQualityNotice = DB::getPDO()->insert('QUALITY_NOTICES', [
+						'NOTICE_INITIAL_TYPE'	=> 'BAD_PROCESS',
+						'ID_PROCES' => '1', //todo: ustalić ID procesu - ustawiłem defaultowo 1!!!!!
+						'NOTICE_REQUEST' => $helpDescription,
+						'NOTICE_REPLY' => '',
+						'NOTICE_REPLY_TYPE' => 'BAD_PROCESS',
+						'L_APPOITMENT_DATE' => 'NOW()',
+						'L_APPOITMENT_USER' => User::getLogin(),
+						'ADM_ACCOUNT' => User::getLogin(),
+						'THIS_SINGLE_WASTE_COST' => '',
+						'WASTE_COST_COMMENT' => '',
+						'THIS_SINGLE_FIX_COST' => '',
+						'YEAR_COST_FOREACST_OF_SUCH_PROBLEM_WITH_FIXING' => '',
+						'FIX_COST_COMMENT' => '',
+						'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
+						'A_RECORD_CREATE_DATE' => 'NOW()'
+					]);
+
+					if( $idQualityNotice > 0 ) {
+							$messageValidate['success'] = 'send';
+
+					} else {
+						$messageValidate['error'] = 2;
+					}
+
+/*
+TODO: dodać możliwość wysyłania maila używajac mail()
+					// Data fpr create mail
 			    $to      = self::$helpEmailTo; // uzupełnić mail
 			    $subject = 'Bocian - formularz pomocy';
-			    $message = "E-mail: " . $helpEmail . ". \r\n Treść wiadomości:\r\n " . $helpDescription;
+			    $message = "Zgłaszający: " . $helpName . " \r\n  E-mail: " . $helpEmail . ". \r\n Treść wiadomości:\r\n " . $helpDescription;
 			    $headers = 'From: '. self::$helpEmailTo . "\r\n" .
 			        'Reply-To: '. self::$helpEmailTo . "\r\n" .
 			        'X-Mailer: PHP/' . phpversion();
@@ -115,9 +141,13 @@ public static $helpEmailTo = 'dariusz@yellowgroup.pl';
 
 					if( $sendMailResponse == true ) {
 							$responseSendMail = true;
+							$messageValidate['success'] = 'send';
+
 					} else {
-						//throw new Exception("Błąd! Wystąpił błąd podczas wysyłania.");
+						$messageValidate['error'] = 2;
 					}
+*/
+
 			}
 
 			include('page-help.view.php');

+ 25 - 5
tools/page-help.view.php

@@ -1,19 +1,39 @@
 <!-- start:form -->
       <form method="POST" >
-        <div id="smad-form-section" class="container">
+        <div id="smad-form-section" class="container" style="padding: 80px 0 80px 0;">
             <div class="row">
                 <div class="smad-form text-center">
                     <div class="smad-form-header">
                         <header>
-                            <h2>WYPEŁNIJ FORMULARZ</h2>
+                          <h1>POMOC</h1>
+                            <h3>Wypełnij formularz</h3>
                         </header>
                     </div>
-                    <? if ($responseSendMail == true) { ?>
+
                     <div class="smad-message">
+                      <?php
+
+                      if ( isset($messageValidate['success']) ) { ?>
                       <div class="success-send alert alert-success">Wiadomość została wysłana</div>
+                      <? } ?>
+                      <?php if ( isset($messageValidate['error']) ) { ?>
+                          <?php if (  $messageValidate['error'] == 1  ) { ?>
+                          <div class="success-send alert alert-danger">"Błąd! Wypełnij poprawnie wszystkie pola"</div>
+                          <? } ?>
+                          <?php if ( $messageValidate['error'] == 2  ) { ?>
+                          <div class="success-send alert alert-danger">Błąd! Wystąpił błąd podczas wysyłania.</div>
+                          <? }
+                        }?>
                     </div>
-                    <? } ?>
+
                     <div class="smad-form-body">
+                      <div class="form-group">
+                        <label class="control-label"><span style="padding-right: 4px;">Zgłaszający</span>
+                        </label>
+                        <div class="">
+                            <input type="text" id="help_name" name="help_name" class="form-control"  disabled value="<?php echo User::getFullName(); ?>">
+                        </div>
+                      </div>
                       <div class="form-group">
                         <label class="control-label"><span style="padding-right: 4px;">Email</span>
                           <i data-toggle="popover" data-trigger="hover" title="" data-content="Email kontaktowy" class="glyphicon glyphicon-info-sign frm-help"></i>
@@ -32,7 +52,7 @@
                       </div>
                     </div>
                     <div class="form-group">
-                        <button type="submit" class="btn btn-primary">WYŚLIJ</button>
+                        <button type="submit" name="button_send" value="1aaa" class="btn btn-primary">WYŚLIJ</button>
                     </div>
                 </div>
             </div>