anketa = $anketa;
SurveyInfo::getInstance()->SurveyInit($this->anketa);
if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
$this->db_table = '_active';
}
function display ($merge = false) {
if ( count($_POST) == 0 ) {
echo '
';
$this->displayAppendMerge($merge);
echo '
';
} else {
$this->do_append_merge();
}
}
function displayAppendMerge ( $merge = false ) {
global $lang, $site_path, $site_url;
$field_list = array();
$sql = sisplet_query("SELECT s.id, s.variable, s.tip FROM srv_spremenljivka s, srv_grupa g WHERE s.gru_id=g.id AND g.ank_id='$this->anketa' AND s.tip IN (1, 2, 3, 7, 8, 21) ORDER BY g.vrstni_red, s.vrstni_red");
while ($row = mysqli_fetch_array($sql)) {
$field_list[$row['id']] = $row['variable'] . ' ('.($row['tip']==1?'radio':'').($row['tip']==2?'checkbox':'').($row['tip']==3?'dropdown':'').($row['tip']==21?'text':'').($row['tip']==7?'number':'').($row['tip']==8?'date':'').')';
}
$import_type = isset($_POST['import_type']) ? (int)$_POST['import_type'] : 2;
session_start();
// Append
if (!$merge){
echo '';
}
// Merge
else{
echo '';
}
}
function do_append_merge() {
global $lang;
global $site_url;
global $global_user_id;
# dodamo uporabnike
$fields = $_POST['fields'];
$recipients_list = mysql_real_unescape_string( $_POST['inv_recipients_list'] );
$merge = (int)$_POST['merge'];
$do_merge = (int)$_POST['do_merge'];
$import_type = (int)$_POST['inv_import_type'];
if ($_POST['do']=='1') $do = true; else $do = false;
// ce uploadamo datoteko
if ($import_type == 1) {
$file_name = $_FILES["recipientsFile"]["tmp_name"];
$fh = @fopen($file_name, "rb");
if ($fh) {
$recipients_list = fread($fh, filesize($file_name));
fclose($fh);
}
if (isset ($_POST['recipientsDelimiter'])) {
$recipients_list = str_replace($_POST['recipientsDelimiter'], "|~|", $recipients_list);
}
else {
$recipients_list = str_replace(",", "|~|", $recipients_list);
}
}
// append
if ($do_merge == 0) {
$result = $this->appendData($do, $fields, $recipients_list);
if ($result == -1) {
$output = $lang['srv_append-merge_required_field'];
} elseif ($result == -3) {
$output = $lang['srv_append-merge_required_data'];
} elseif ($result >= 0) {
$output = $lang['srv_append-merge_added_1'].' '.$result.' '.$lang['srv_append-merge_added_2'];
}
// merge
} elseif ($do_merge == 1) {
$result = $this->mergeData($do, $fields, $recipients_list, $merge);
if ($result == -1) {
$output = $lang['srv_append-merge_required_field'];
} elseif ($result == -2) {
$output = $lang['srv_append-merge_required_id'];
} elseif ($result == -3) {
$output = $lang['srv_append-merge_required_data'];
} elseif ($result >= 0) {
$output = $lang['srv_append-merge_merged_1'].' '.$result.' '.$lang['srv_append-merge_merged_2'];
}
}
// prikazemo obvestilo in formo za potrditev
if ($import_type == 1){
if ($do_merge == 1)
echo '