';
// Loop cez vse stranke
- foreach($this->clients as $client_id => $client){
+ $responses = $this->getResponses();
+ foreach($responses as $reponse_id => $reponse){
- echo '
';
+ echo '
';
- var_dump($client);
+ var_dump($reponse);
echo '
';
}
@@ -94,16 +110,142 @@ class Kolektor {
}
// Prikaze formo za dodajanje novega responsa
- public function displayAddResponse(){
+ public function displayAddResponse($data=array(), $error=array()){
+
+ echo '
';
}
public function displayResponseDetails(){
+ }
+
+
+ // Ajax klici
+ public function ajax(){
+ global $lang;
+ global $site_path;
+ global $global_user_id;
+
+
+ if($_GET['a'] == 'add_repsonse'){
+
+ $response_data['ank_id'] = (isset($_POST['kolektor_survey'])) ? $_POST['kolektor_survey'] : '';
+ $response_data['respondent_email'] = (isset($_POST['respondent_email'])) ? $_POST['respondent_email'] : '';
+ $response_data['respondent_funkcija'] = (isset($_POST['respondent_funkcija'])) ? $_POST['respondent_funkcija'] : '';
+ $response_data['respondent_projekt_id'] = (isset($_POST['respondent_projekt_id'])) ? $_POST['respondent_projekt_id'] : '';
+ $response_data['respondent_remote_activation'] = (isset($_POST['respondent_remote_activation'])) ? $_POST['respondent_remote_activation'] : '';
+ $response_data['respondent_message'] = (isset($_POST['respondent_message'])) ? $_POST['respondent_message'] : '';
+
+
+ // Pohendlamo errorje
+ $error = array();
+ if($response_data['ank_id'] == ''){
+ $error['ank_id'] = 'Izberite anketo.';
+ }
+ if($response_data['respondent_email'] == ''){
+ $error['respondent_email'] = 'Vnesite email respondenta.';
+ }
+ if($response_data['respondent_funkcija'] == ''){
+ $error['respondent_funkcija'] = 'Vnesite funkcijo respondenta.';
+ }
+ if($response_data['respondent_projekt_id'] == ''){
+ $error['respondent_projekt_id'] = 'Vnesite ID projekta oz. krovnega projekta.';
+ }
+ if($response_data['respondent_remote_activation'] == ''){
+ $error['respondent_remote_activation'] = 'Izberite, če gre za aktivacijo na daljavo.';
+ }
+ if($response_data['respondent_message'] == ''){
+ $error['respondent_message'] = 'Vnesite spremno besedilo.';
+ }
+
+
+ // Imamo napake
+ if(!empty($error)){
+ $this->displayAddResponse($response_data, $error);
+ }
+ else{
+ // Dodamo nov response
+ KolektorResponse::addResponse($response_data);
+ }
+ }
+
}
}
diff --git a/admin/survey/modules/mod_KOLEKTOR/class.KolektorResponse.php b/admin/survey/modules/mod_KOLEKTOR/class.KolektorResponse.php
index 403ce5b54..2d030b361 100644
--- a/admin/survey/modules/mod_KOLEKTOR/class.KolektorResponse.php
+++ b/admin/survey/modules/mod_KOLEKTOR/class.KolektorResponse.php
@@ -30,9 +30,11 @@ class KolektorResponse {
// Dodajanje responsa
public static function addResponse($response_data){
+ global $global_user_id;
// Dodaj respondenta v srv_user
+ $respondent_id = 20;
// Poslji email z vabilom na anketo
@@ -40,20 +42,44 @@ class KolektorResponse {
// Dodaj respondenta v kolektor bazo
$sql = sisplet_query("INSERT INTO kolektor_survey_response
- (ank_id, usr_id, inser_time, status, kolektor_client_id, respondent_id)
+ (ank_id,
+ usr_id,
+ insert_time,
+ status,
+ respondent_id,
+ respondent_email,
+ respondent_funkcija,
+ respondent_projekt_id,
+ respondent_remote_activation,
+ respondent_message)
VALUES
- ('".$response_data['ank_id']."', '".$response_data['usr_id']."', NOW(), '0', '".$response_data['kolektor_client_id']."', '".$response_data['respondent_id']."')
+ ('".$response_data['ank_id']."',
+ '".$global_user_id."',
+ NOW(),
+ '0',
+ '".$respondent_id."',
+ '".$response_data['respondent_email']."',
+ '".$response_data['respondent_funkcija']."',
+ '".$response_data['respondent_projekt_id']."',
+ '".$response_data['respondent_remote_activation']."',
+ '".$response_data['respondent_message']."')
");
+ if (!$sql){
+ echo mysqli_error($GLOBALS['connect_db']);
+ return false;
+ }
+
$response_id = mysqli_insert_id($GLOBALS['connect_db']);
- /*if($response = new KolektorResponse($response_id)){
+ if($response = new KolektorResponse($response_id)){
+ echo 'Anketa je bila uspešno sprožena in email je bil uspešno poslan respondentu ('.$response_data['respondent_email'].').';
return $response;
}
else{
echo 'Napaka pri dodajanju odgovora!';
return false;
- }*/
+ }
}
}
diff --git a/admin/survey/modules/mod_KOLEKTOR/script/script.js b/admin/survey/modules/mod_KOLEKTOR/script/script.js
index e69de29bb..535d6cfb9 100644
--- a/admin/survey/modules/mod_KOLEKTOR/script/script.js
+++ b/admin/survey/modules/mod_KOLEKTOR/script/script.js
@@ -0,0 +1,8 @@
+
+function createKolektorResponse(){
+
+ var form = $("#kolektor_add_response_form").serializeArray();
+
+ $('#kolektor_add_response').load('ajax.php?t=kolektor&a=add_repsonse', form);
+
+}
\ No newline at end of file
diff --git a/sql/update2.sql b/sql/update2.sql
index 4deec8e6f..9f3114205 100644
--- a/sql/update2.sql
+++ b/sql/update2.sql
@@ -9597,22 +9597,11 @@ UPDATE misc SET value='22.06.14' WHERE what="version";
INSERT INTO srv_module (module_name, active) VALUES ('kolektor', '0');
#UPDATE srv_module SET active='1' WHERE module_name = 'kolektor';
-CREATE TABLE kolektor_sequence(
+CREATE TABLE kolektor_survey(
id INT(11) NOT NULL auto_increment,
- ank1_id INT(11) NOT NULL DEFAULT '0',
- ank2_id INT(11) NOT NULL DEFAULT '0',
- ank3_id INT(11) NOT NULL DEFAULT '0',
- ank4_id INT(11) NOT NULL DEFAULT '0',
- ank5_id INT(11) NOT NULL DEFAULT '0',
- ank6_id INT(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE kolektor_client(
- id INT(11) NOT NULL auto_increment,
- usr_id INT(11) NOT NULL DEFAULT 0,
- insert_time DATETIME(3) NOT NULL,
- CONSTRAINT fk_kolektor_client_usr_id FOREIGN KEY (usr_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ ank_id INT(11) NOT NULL DEFAULT '0',
+ survey_sequence ENUM('1','2','3','4','5','6') NOT NULL,
+ CONSTRAINT fk_kolektor_survey_ank_id FOREIGN KEY (ank_id) REFERENCES srv_anketa (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -9622,7 +9611,6 @@ CREATE TABLE kolektor_survey_response(
usr_id INT(11) NOT NULL DEFAULT 0,
insert_time DATETIME(3) NOT NULL,
status ENUM('0','1','2','3','4') NOT NULL DEFAULT '0',
- kolektor_client_id INT(11) NOT NULL DEFAULT 0,
respondent_id INT(11) NOT NULL DEFAULT 0,
respondent_email VARCHAR(100) NOT NULL DEFAULT '',
respondent_funkcija VARCHAR(100) NOT NULL DEFAULT '',
@@ -9631,7 +9619,6 @@ CREATE TABLE kolektor_survey_response(
respondent_message TEXT NOT NULL DEFAULT '',
CONSTRAINT fk_kolektor_survey_response_ank_id FOREIGN KEY (ank_id) REFERENCES srv_anketa (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_kolektor_survey_response_usr_id FOREIGN KEY (usr_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT fk_kolektor_survey_response_kolektor_client_id FOREIGN KEY (kolektor_client_id) REFERENCES kolektor_client (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_kolektor_survey_response_respondent_id FOREIGN KEY (respondent_id) REFERENCES srv_user (id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -9639,7 +9626,7 @@ CREATE TABLE kolektor_survey_response(
CREATE TABLE kolektor_survey_response_alert(
kolektor_survey_response_id INT(11) NOT NULL,
alert_time DATETIME(3) NOT NULL,
- status ENUM('0','1','2','3','4') NOT NULL,
+ new_status ENUM('0','1','2','3','4') NOT NULL,
CONSTRAINT kolektor_survey_response_alert_kolektor_survey_response_id FOREIGN KEY (kolektor_survey_response_id) REFERENCES kolektor_survey_response (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;