|
From: <si...@us...> - 2006-04-03 23:45:51
|
Revision: 610 Author: sickpig Date: 2006-04-03 16:45:34 -0700 (Mon, 03 Apr 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=610&view=rev Log Message: ----------- * first step toward new db design. (this stuff it's quite unusable by now) Modified Paths: -------------- trunk/yacati.tcl trunk/yadmin.tcl Modified: trunk/yacati.tcl =================================================================== --- trunk/yacati.tcl 2006-04-03 23:39:28 UTC (rev 609) +++ trunk/yacati.tcl 2006-04-03 23:45:34 UTC (rev 610) @@ -193,8 +193,8 @@ # Grid 2 labelframe .g0b.g2 -relief flat -button .g0b.g2.btel1 -text [mc "Telephone 1"] -state disabled -command { yacati::onChangePhoneState $db_sample 1 } -disabledforeground $::yacati::dfblack -button .g0b.g2.btel2 -text [mc "Telephone 2"] -state disabled -command { yacati::onChangePhoneState $db_sample 2 } -disabledforeground $::yacati::dfblack +button .g0b.g2.btel1 -text [mc "Telephone 1"] -state disabled -command { yacati::onChangePhoneState $db 1 } -disabledforeground $::yacati::dfblack +button .g0b.g2.btel2 -text [mc "Telephone 2"] -state disabled -command { yacati::onChangePhoneState $db 2 } -disabledforeground $::yacati::dfblack label .g0b.g2.lbtel3 -text [mc "Telephone 3"] label .g0b.g2.lbtel4 -text [mc "Telephone 4"] label .g0b.g2.lbnum_int -text [mc "Num int"] @@ -214,10 +214,10 @@ radiobutton .g0b.g2.cbtel3 -value 3 -variable yacati::CkTel -command { yacati::onPressTel 3 } radiobutton .g0b.g2.cbtel4 -value 4 -variable yacati::CkTel -command { yacati::onPressTel 4 } button .g0b.g2.btsend_fax -image $::yatk_icons::fax -text [mc "Send fax"] -compound left \ - -state disabled -command { yacati::onPressFax $db_sample $db_int $yacati::config(FAX_SERVER)} + -state disabled -command { yacati::onPressFax $db $yacati::config(FAX_SERVER)} ::yatk_balloon::balloon .g0b.g2.btsend_fax [mc "Send survey presentation via fax"] button .g0b.g2.btsend_email -image $::yatk_icons::email -text [mc "Send email"] -compound left \ - -state disabled -command { yacati::onPressEmail $db_sample $db_int $yacati::config(MAIL_SERVER) $yacati::config(MAIL_SENDER)} + -state disabled -command { yacati::onPressEmail $db $yacati::config(MAIL_SERVER) $yacati::config(MAIL_SENDER)} ::yatk_balloon::balloon .g0b.g2.btsend_email [mc "Send survey presentation via email"] message .g0b.g2.msg -text "" -relief groove -width 200 label .g0b.g2.lsugg2 -text "" -relief groove -width 25 -wraplength 150 @@ -284,10 +284,10 @@ iwidgets::combobox .g5.cbcon_state -state disabled -completion false entry .g5.eretry -width 2 -disabledforeground $::yacati::dfblack -state disabled button .g5.btreplay -image $::yatk_icons::reply -text [mc "Reply"] -compound left \ - -state disabled -command {::yacati::onPressReplay $db_sample $db_int $yacati::config(CATIEXE)} + -state disabled -command {::yacati::onPressReplay $db $yacati::config(CATIEXE)} ::yatk_balloon::balloon .g5.btreplay [mc "Let the contact answer the survey"] button .g5.btappointment -image $::yatk_icons::date -text [mc "Appointment"] -compound left \ - -state disabled -command { yacati::onPressAppointment $db_sample $db_int } + -state disabled -command { yacati::onPressAppointment $db } ::yatk_balloon::balloon .g5.btappointment [mc "Schedule a call-back"] grid .g5.lbstate .g5.cbcon_state .g5.lbretry .g5.eretry .g5.btreplay .g5.btappointment -sticky ew @@ -301,19 +301,19 @@ labelframe .g6 -relief flat -padx 4 -pady 4 button .g6.btbegin -image $::yatk_icons::start -text [mc "Begin"] -compound left \ - -command { yacati::onPressBegin $db_sample $db_int } + -command { yacati::onPressBegin $db } ::yatk_balloon::balloon .g6.btbegin [mc "Start your turn"] button .g6.btnew_contact -image $::yatk_icons::new -text [mc "New contact"] -compound left \ - -state disabled -command { ::yacati::onPressNew_contact $db_sample $db_int } + -state disabled -command { ::yacati::onPressNew_contact $db } ::yatk_balloon::balloon .g6.btnew_contact [mc "Get a new contact"] button .g6.btsave -image $::yatk_icons::save -text [mc "Save"] -compound left \ - -state disabled -command { yacati::onPressSave $db_sample $db_int} + -state disabled -command { yacati::onPressSave $db $db} ::yatk_balloon::balloon .g6.btsave [mc "Save the contact"] button .g6.btfinish -image $::yatk_icons::exit -text [mc "Finish"] -compound left \ - -state disabled -command { yacati::onPressFinish $db_sample $db_int } + -state disabled -command { yacati::onPressFinish $db } ::yatk_balloon::balloon .g6.btfinish [mc "Finish your turn"] button .g6.btpause -image $::yatk_icons::pause -text [mc "Pause"] -compound left \ - -state disabled -command { yacati::onPressPause $db_sample $db_int } + -state disabled -command { yacati::onPressPause $db } ::yatk_balloon::balloon .g6.btpause [mc "Get a rest"] grid .g6.btbegin .g6.btnew_contact .g6.btsave .g6.btfinish .g6.btpause -sticky news -padx 10 @@ -581,13 +581,12 @@ # Enevet onPress of the button 'Begin'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc ::yacati::onPressBegin {db_sample db_int} { +# @param db - db connection handler +proc ::yacati::onPressBegin {db} { global pjName - set pjList [cati::getProjList $db_sample 1] + set pjList [cati::getProjList $db 1] if { $pjList == -1 } { yatk_dlg::error [mc "Unable to retrive project list, check your log"] return @@ -601,28 +600,27 @@ return } - yacati::openSurvey $db_sample $db_int $pjName + yacati::openSurvey $db $pjName wm protocol . WM_DELETE_WINDOW {puts -nonewline ""} } # Enevet onPress of the button 'New contact'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc ::yacati::onPressNew_contact {db_sample db_int} { +# @param db - db connection handler +proc ::yacati::onPressNew_contact {db} { array set survey [array get yacati::survey] if {$yacati::call==0} { yalog::debug "Button newcontact pressed..." - set risu [yacati::get_contact $db_sample $db_int] - if {$yacati::survey(azienda)=="t"} {::yacati::incWdjState normal} else {::yacati::popWdjState normal} + set risu [yacati::get_contact $db] + if {$yacati::survey(listed)=="t"} {::yacati::incWdjState normal} else {::yacati::popWdjState normal} set yacati::disabledPhones [list] set yacati::enabledPhones [list] if {($risu==0)} { if { $survey(freq_mon)!=0 && $survey(freq_att)==0 } { - set ::yacati::perfIdxs [cati::perfIdxCalc $db_sample $db_int $survey(idindagine) $yacati::session(inizio_turno) $yacati::user(id)] + set ::yacati::perfIdxs [cati::perfIdxCalc $db $survey(proj) $yacati::session(inizio_turno) $yacati::user(id)] } ::yacati::perfIdxDisplay $::yacati::perfIdxs @@ -662,9 +660,8 @@ # Event onPress of the button 'Save'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc ::yacati::onPressSave {db_sample db_int} { +# @param db - db connection handler +proc ::yacati::onPressSave {db} { array set contact [array get ::yacati::contact] array set survey [array get ::yacati::survey] array set user [array get ::yacati::user] @@ -672,9 +669,13 @@ ::yalog::debug "I save the contact state..." # which contact state was choose - set valore_str [::yacati::getWdjValue con_state]; - set idsta [::yadb::getTuple $db_sample "Select idstato from stato_contatto where nomestato::bpchar='$valore_str'" 0]; - array set edata [::yacati::prepareSave $idsta] + set ouid [::cati::getOuidByOutcome $db [::yacati::getWdjValue con_state]]; + if {$ouid == -1} { + ::yalog::error "Unable to retrive outcome id" + ::yatk_dlg::error "Unable to retrive outcome id" + return + } + array set edata [::yacati::prepareSave $ouid] if { [info exists edata(err)] } { if {$edata(err)==-1} {return [::yatk_dlg::error [mc "Wrong email format, please re-check or leave it blank"]]} if {$edata(err)==-2} {return [::yatk_dlg::error [mc "You're tring to save a contact without associate phone number"]]} @@ -682,7 +683,7 @@ } set contact(note) $edata(note) - if { $idsta!=8 } { + if { $ouid!=8 } { set cInden 0 if {$::yacati::sex && [::yacati::get_active_sex]!=""} { set cInden 1} if {$::yacati::age && [::yacati::getWdjValue birthday]!=""} { set cInden 1} @@ -693,7 +694,7 @@ } } - if {$idsta==8} { + if {$ouid==8} { if { $survey(azienda) == "f" } { if {$::yacati::age} { @@ -712,7 +713,7 @@ if {$::yacati::work} { set valore_str2 [::yacati::getWdjValue work]; - set atti [::yadb::getTuple $db_sample "Select id_attivita from attivita where tipo_attivita='$valore_str2'" 0] + set atti [::yadb::getTuple $db "Select id_attivita from attivita where tipo_attivita='$valore_str2'" 0] if {$atti==-1} { set ::yacati::nome_usato 0; return [::yatk_dlg::error [mc "Work is not correct"]] @@ -721,7 +722,7 @@ if {$::yacati::study} { set valore_str2 [yacati::getWdjValue study] - set studi [::yadb::getTuple $db_sample "Select id_titolo from titolo_studio where titolo='$valore_str2'" 0] + set studi [::yadb::getTuple $db "Select id_titolo from titolo_studio where titolo='$valore_str2'" 0] if {$studi==-1} { set ::yacati::nome_usato 0; return [::yatk_dlg::error [mc "Study degree is not correct."]] @@ -756,13 +757,13 @@ } } else { set sex "N"} - set sql "Select ins_anagrafica( $contact(id),$contact(com_sql),$survey(idindagine),$year,$atti,$studi,'$sex',$vol_str)" - ::yadb::execl $db_sample $sql + set sql "Select projects.ins_respondent( $contact(uid),$contact(com_sql),$survey(proj),$year,$atti,$studi,'$sex',$vol_str)" + ::yadb::execl $db $sql } else { if { $yacati::CkFax } { ::yalog::debug "Send a presentation fax while save a completed interviews" - set resList [::yacati::sendFaxWrap $db_sample $::yacati::config(FAX_SERVER) [array get edata]] + set resList [::yacati::sendFaxWrap $db $::yacati::config(FAX_SERVER) [array get edata]] if { [lindex $resList 0] } { return [::yatk_dlg::error [lindex $resList 1]] } @@ -773,15 +774,15 @@ } - if {[::cati::saveContact $db_sample $db_int $idsta $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ + if {[::cati::saveContact $db $ouid $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ [::yacati::getWdjValue tel3] [yacati::getWdjValue tel4] [array get survey] [array get contact] [array get user] $edata(email)] == -1} { return [::yatk_dlg::error [mc "Error while saving contact's data. Please contact YaaCs's administrator"]] } - ::yacati::managePhones $db_sample + ::yacati::managePhones $db ::yalog::debug "Close session_activity $contact(s_activity)" - ::cati::closeSessionActivity $db_int $contact(s_activity) $idsta + ::cati::closeSessionActivity $db $contact(s_activity) $ouid ::yalog::debug "--End I save the contact state --" @@ -791,27 +792,26 @@ # Event onPress of the button 'Finish'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc ::yacati::onPressFinish {db_sample db_int} { +# @param db - db connection handler +proc ::yacati::onPressFinish {db} { array set contact [array get yacati::contact] array set survey [array get yacati::survey] array set user [array get yacati::user] array set session [array get yacati::session] - yalog::debug "-- End turn --" + ::yalog::debug "-- End turn --" set aperta_masc 0; #try another trick this one is extremly ugly set nome [yacati::getWdjValue company_name] - if { $yacati::nome_usato==0 && $contact(nome)!="" } { + if { $yacati::nome_usato==0 && $contact(name)!="" } { set aperta_masc [yatk_dlg::alert [mc "Warning you didn't save the date of the contact. Do you really want to exit?"]] if {$aperta_masc == 0} { - ::cati::exitWithoutSaving $db_sample $yacati::user(id) [array get contact] [array get survey] - ::cati::closeSessionActivity $db_int $contact(s_activity) $::yacati::avoidSessionCode + ::cati::exitWithoutSaving $db $yacati::user(uid) [array get contact] [array get survey] + ::cati::closeSessionActivity $db $contact(s_activity) $::yacati::avoidSessionCode set yacati::call 0 yacati::configureWdj bt_new state normal yacati::configureWdj bt_new text [mc "New Contact"] @@ -822,7 +822,7 @@ if {$aperta_masc == 0} { - set reslist [::cati::exit $db_sample $db_int [array get contact] [array get survey] \ + set reslist [::cati::exit $db [array get contact] [array get survey] \ [array get user] [array get session] $::yacati::have_you_ever_be_detected [lindex $::yacati::perfIdxs 0]] yacati::clearMask @@ -834,11 +834,10 @@ ::yacati::setWdjValue voip_static "" disabled set ::yavoip::status "" - ::yacati::exitWindow $db_int $db_sample $reslist $survey(nome_tabella) $session(num_risp_turno) $::yacati::have_you_ever_be_detected $survey(idindagine) + ::yacati::exitWindow $db $reslist $survey(name) $session(num_risp_turno) $::yacati::have_you_ever_be_detected $survey(proj) wm protocol . WM_DELETE_WINDOW { - ::yadb::disconnect $db_int - ::yadb::disconnect $db_sample + ::yadb::disconnect $db if {$::yacati::autodial} { ::yavoip::reset } @@ -851,17 +850,17 @@ # Prepare the GUI after user pause # -# @param db_int the handler of db int +# @param db - db connection handler # @param userid user id -proc yacati::onPauseUnlock {db_int userid} { +proc yacati::onPauseUnlock {db userid} { ::yalog::debug "Close pause session" - ::cati::closeSessionActivity $db_int $yacati::p_session -1 + ::cati::closeSessionActivity $db $yacati::p_session -1 set sql_note_user "select note from intervistatore where id=$userid" - set note_user [lindex [::yadb::getTuple $db_int $sql_note_user 0] 0] + set note_user [lindex [::yadb::getTuple $db $sql_note_user 0] 0] regsub -all \\n $note_user "" note_user - set lastIdxs [::bbtools::lastNCompPerf $db_int $userid 4] + set lastIdxs [::bbtools::lastNCompPerf $db $userid 4] set strLast "" foreach l $lastIdx { set strLast "$strLast\[$l\] " @@ -883,27 +882,25 @@ # Event onPress of the button 'Pause'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc yacati::onPressPause { db_sample db_int } { +# @param db - db connection handler +proc yacati::onPressPause {db} { array set survey [array get ::yacati::survey] array set user [array get ::yacati::user] ::yalog::debug "Start pause session" - set ::yacati::p_session [::cati::getSessionActivity $db_int $user(id) $survey(idindagine) 0 0] + set ::yacati::p_session [::cati::getSessionActivity $db $user(uid) $survey(proj) 0 0] ::yacati::configureWdj bt_new state disabled; ::yacati::configureWdj bt_finish state disabled; - set ::yacati::t_init_pausa [lindex [yadb::getTimeSec $db_sample] 1] - ::yacati::managePause $db_sample $db_int $::yacati::t_init_pausa - ::yacati::onPauseUnlock $db_int $user(id) + set ::yacati::t_init_pausa [lindex [yadb::getTimeSec $db] 1] + ::yacati::managePause $db $::yacati::t_init_pausa + ::yacati::onPauseUnlock $db $user(uid) return } # Event onPress of the button 'Reply'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc yacati::onPressReplay { db_sample db_int cati_exe} { +# @param db - db connection handler +proc yacati::onPressReplay { db cati_exe} { array set survey [array get yacati::survey] array set contact [array get yacati::contact] set url $survey(url) @@ -942,9 +939,8 @@ # Event onPress of the button 'Appointment'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc yacati::onPressAppointment { db_sample db_int } { +# @param db - db connection handler +proc yacati::onPressAppointment {db} { array set contact [array get yacati::contact] array set survey [array get yacati::survey] array set user [array get yacati::user] @@ -963,13 +959,13 @@ [::yacati::getWdj con_state] configure -state normal yacati::clearCombo con_state - array set ret [::yacati::callBack $db_sample $survey(idindagine) $survey(inizio) $survey(fine) \ + array set ret [::yacati::callBack $db $survey(proj) $survey(pjstart) $survey(pjend) \ $survey(azienda) [array get contact]] if {[array size ret] == 0} { yalog::debug "Operators press cancel on Call Back GUI"; return } - set risu [cati::saveContact $db_sample $db_int 9 $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ - [yacati::getWdjValue tel3] [yacati::getWdjValue tel4] [array get survey] [array get contact] \ + set risu [::cati::saveContact $db 9 $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ + [::yacati::getWdjValue tel3] [::yacati::getWdjValue tel4] [array get survey] [array get contact] \ [array get user] $edata(email) $ret(timestamp)] if {$risu == -1} { @@ -982,19 +978,19 @@ regsub -all \' $ret(nomeapp) \\' ret(nomeapp) - set sql_appstuff "update appuntamenti set nome='$ret(nomeapp)', anno_nascita=$ret(annoapp), genere='$ret(sexapp)', \ - uid=$user(id) where id=$contact(id) and cod_com=$contact(com_sql) and idindagine=$survey(idindagine)" + set sql_appstuff "update projects.schedule set name='$ret(nomeapp)', byear=$ret(annoapp), sex='$ret(sexapp)', \ + uid=$user(uid) where rid=$contact(rid) and cod_com=$contact(com_sql) and proj=$survey(proj)" - if {[yadb::execl $db_sample $sql_appstuff] == -1} { + if {[yadb::execl $db $sql_appstuff] == -1} { yatk_dlg::error [mc "Error on saving call back infos. Check them and try again"] } yalog::debug "contact's info and call back saved" - yacati::managePhones $db_sample + yacati::managePhones $db ::yalog::debug "Close session_activity $contact(s_activity)" - ::cati::closeSessionActivity $db_int $contact(s_activity) 9 + ::cati::closeSessionActivity $db $contact(s_activity) 9 ::yacati::configureWdj bbr state normal @@ -1008,31 +1004,30 @@ # Event onPress of the button 'Fax'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int +# @param db - db connection handler # @param faxserver ip faxserver address -proc ::yacati::onPressFax {db_sample db_int faxserver} { +proc ::yacati::onPressFax {db faxserver} { array set survey [array get yacati::survey] array set contact [array get yacati::contact] array set user [array get yacati::user] - array set edata [yacati::prepareSave 10] + array set edata [::yacati::prepareSave 10] if { [info exists edata(err)] } { - if {$edata(err)==-1} {return [yatk_dlg::error [mc "Wrong email format, please re-check or leave it blank"]]} - if {$edata(err)==-2} {return [yatk_dlg::error [mc "You're tring to save a contact without associate phone number"]]} - if {$edata(err)==-3} {return [yatk_dlg::error [mc "Warning, you have choose an invalid constact state"]]} + if {$edata(err)==-1} {return [::yatk_dlg::error [mc "Wrong email format, please re-check or leave it blank"]]} + if {$edata(err)==-2} {return [::yatk_dlg::error [mc "You're tring to save a contact without associate phone number"]]} + if {$edata(err)==-3} {return [::yatk_dlg::error [mc "Warning, you have choose an invalid constact state"]]} } set contact(note) $edata(note) - set resList [::yacati::sendFaxWrap $db_sample $faxserver [array get edata]] + set resList [::yacati::sendFaxWrap $db $faxserver [array get edata]] if { [lindex $resList 0] } { - return [yatk_dlg::error [lindex $resList 1]] + return [::yatk_dlg::error [lindex $resList 1]] } else { set yacati::stato_fax 1; yacati::clearCombo con_state - if {[cati::saveContact $db_sample $db_int 10 $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ - [yacati::getWdjValue tel3] [yacati::getWdjValue tel4] [array get survey] [array get contact] [array get user] $edata(email)] == -1} { - return [yatk_dlg::error [mc "Error while saving contact's data. Please contact YaaCs's administrator"]] + if {[cati::saveContact $db 10 $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ + [::yacati::getWdjValue tel3] [::yacati::getWdjValue tel4] [array get survey] [array get contact] [array get user] $edata(email)] == -1} { + return [::yatk_dlg::error [mc "Error while saving contact's data. Please contact YaaCs's administrator"]] } yacati::configureWdj bbr state normal @@ -1045,10 +1040,10 @@ ::yatk_dlg::info [mc "Fax sent."] - ::yacati::managePhones $db_sample + ::yacati::managePhones $db ::yalog::debug "Close session_activity $contact(s_activity)" - ::cati::closeSessionActivity $db_int $contact(s_activity) 10 + ::cati::closeSessionActivity $db $contact(s_activity) 10 ::yalog::debug "--End I save the contact state --" ::yacati::clearMask @@ -1058,24 +1053,23 @@ # Event onPress of the button 'Email'. # -# @param db_samlpe the handler of db sample -# @param db_int the handler of db int -proc ::yacati::onPressEmail { db_sample db_int smtpd fromaddr} { - array set survey [array get yacati::survey] - array set contact [array get yacati::contact] - array set user [array get yacati::user] - set home [yaconf::checkLocalConf] +# @param db - db connection handler +proc ::yacati::onPressEmail { db smtpd fromaddr} { + array set survey [array get ::yacati::survey] + array set contact [array get ::yacati::contact] + array set user [array get ::yacati::user] + set home [::yaconf::checkLocalConf] - array set edata [yacati::prepareSave 10] + array set edata [::yacati::prepareSave 10] if { [info exists edata(err)] } { - if {$edata(err)==-1} {return [yatk_dlg::error [mc "Wrong email format, please re-check"]]} - if {$edata(err)==-2} {return [yatk_dlg::error [mc "You're tring to save a contact without associate phone number"]]} - if {$edata(err)==-3} {return [yatk_dlg::error [mc "Warning, you have choose an invalid constact state"]]} + if {$edata(err)==-1} {return [::yatk_dlg::error [mc "Wrong email format, please re-check"]]} + if {$edata(err)==-2} {return [::yatk_dlg::error [mc "You're tring to save a contact without associate phone number"]]} + if {$edata(err)==-3} {return [::yatk_dlg::error [mc "Warning, you have choose an invalid constact state"]]} } - if { $edata(email) == "" || [sendmail::validateMail $edata(email)]==0 } {return [yatk_dlg::error [mc "Email addess is invalid."]]} + if { $edata(email) == "" || [::sendmail::validateMail $edata(email)]==0 } {return [yatk_dlg::error [mc "Email addess is invalid."]]} set contact(note) $edata(note) - if { $survey(azienda)=="t" } { + if { $survey(listed)=="t" } { set referente [yacati::getWdjValue ref]; set referente [string trim $referente]; if { $referente == ""} { @@ -1086,12 +1080,12 @@ } set modello_testo "" - set res_mod [yadb::getTuple $db_sample "Select btrim(percorso_mail),btrim(descrizione) from indagini where idindagine = $survey(idindagine)" 0] + set res_mod [yadb::getTuple $db "Select btrim(mail_path),btrim(description) from projects.projects where proj = $survey(proj)" 0] set modello_testo [lindex $res_mod 0] set subject [lindex $res_mod 1] if {("$fromaddr" == "") || ("$modello_testo" == "")} { - yalog::error "Problem with yaacs configuration, check MAIL_SERVER, MAIL_SENDER values or field 'percorso_mail' on table 'indagini'" + yalog::error "Problem with yaacs configuration, check MAIL_SERVER, MAIL_SENDER values or field 'mail_path' on table 'projects.projects'" return [yatk_dlg::error [mc "Problem with yaacs configuration, check \ MAIL_SERVER, MAIL_SENDER values or field 'percorso_mail' on table 'indagini'."]] } @@ -1103,7 +1097,7 @@ set body "" foreach line [split $body_a \n] { set line [string map [list REFERENTE $referente] $line] - set line [string map [list RAGIONE_SOCIALE $contact(nome)] $line] + set line [string map [list RAGIONE_SOCIALE $contact(name)] $line] set line [string map [list US $contact(adde)] $line] set line [string map [list PASS $contact(sett)] $line] set body "$body$line\n" @@ -1121,16 +1115,16 @@ set default_esito "True" #Il campo cod_com della tabella log_mail viene lasciato vuoto nel caso si lavori con aziende - set sql "Insert into log_mail (addr,idindagine,idintervistatore,esito,id,quando,cod_com) \ - values ( '$edata(email)', $survey(idindagine), $user(id), $default_esito, $contact(id), now(), $contact(com_sql))"; - yadb::execl $db_sample $sql + set sql "Insert into log.mail (addr,proj,uid,status,rid,touch,cod_com) \ + values ( '$edata(email)', $survey(proj), $user(uid), $default_esito, $contact(rid), now(), $contact(com_sql))"; + yadb::execl $db $sql - if {[cati::saveContact $db_sample $db_int 10 $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ - [yacati::getWdjValue tel3] [yacati::getWdjValue tel4] [array get survey] [array get contact] [array get user] $edata(email)] == -1} { - return [yatk_dlg::error [mc "Error while saving contact's data. Please contact YaaCs's administrator"]] + if {[cati::saveContact $db 10 $edata(ref) $edata(notes) $edata(fax) $edata(active_phone) \ + [yacati::getWdjValue tel3] [::yacati::getWdjValue tel4] [array get survey] [array get contact] [array get user] $edata(email)] == -1} { + return [::yatk_dlg::error [mc "Error while saving contact's data. Please contact YaaCs's administrator"]] } - yacati::configureWdj bbr state normal + ::yacati::configureWdj bbr state normal if {$yacati::autodial==1} { set ::yacati::manualSave 1 @@ -1138,12 +1132,12 @@ yalog::debug "hang up the phone, while sending email " } - yatk_dlg::info [mc "Email sent."] + ::yatk_dlg::info [mc "Email sent."] - yacati::managePhones $db_sample + ::yacati::managePhones $db yalog::debug "Close session_activity $contact(s_activity)" - ::cati::closeSessionActivity $db_int $contact(s_activity) 10 + ::cati::closeSessionActivity $db $contact(s_activity) 10 yalog::debug "--End I save the contact state --" yacati::clearMask @@ -1153,9 +1147,9 @@ # This event is triggered when a user try to disable a # phone number by the button 'Telephone 1' and 'Telephone 2' # -# @param db_samlpe the handler of db sample +# @param db - db connection handler # @param phone the number of the phone wdj, beetwen 1 and 4 -proc yacati::onChangePhoneState { db_sample phone} { +proc yacati::onChangePhoneState {db phone} { set cnt [yacati::count_phones] if { $cnt == 0 } return if {[string length [::yacati::getWdjValue "tel$phone"]]==0} { @@ -1177,7 +1171,9 @@ if {$idxEna != -1} { set old_phone 0 } else { - set old_phone [yadb::getTuple $db_sample "SELECT tel_disabled$phone FROM $yacati::survey(nome_tabella) WHERE id=$yacati::contact(id)" 0] + # MOVE SQL + set old_phone [yadb::getTuple $db "SELECT dis_phone$phone FROM projects.$yacati::survey(pjtable)\ + WHERE rid=$yacati::contact(rid)" 0] } } @@ -1265,44 +1261,44 @@ # If the survey you're trying to open doesn't exist # it exits with a panic message. # -# @param db_sample the handler of db sample -# @param db_int the handler of db int +# @param db - db connectionhandler # @param project the name of the survey to open -proc ::yacati::openSurvey {db_sample db_int project} { +proc ::yacati::openSurvey {db project} { set user_name [::yaconf::getUser] - array set yacati::survey [::cati::getSurveyFromTitle $db_sample $project] - if { [array size yacati::survey] == 0 } { + array set yacati::survey [::cati::getSurveyFromTitle $db $project] + if { [array size ::yacati::survey] == 0 } { ::yalog::panic [mc "Sorry, you have choose an invalid survey."] } - ::yacati::updatePanelPop $yacati::survey(azienda) + ::yacati::updatePanelPop $::yacati::survey(listed) if {[array size ::yacati::survey]==0} {return ::yatk_dlg::error [mc "This survey does not exists"]} - array set ::yacati::user [::cati::getUserInfo $db_int $user_name] + array set ::yacati::user [::cati::getUserInfo $db $user_name] if {[array size ::yacati::user]==0} {return [::yatk_dlg::error [mc "Your account is not present on the system, please contact the syetem administrator!"]]} - if {[yadb::getNumTuples $db_int "Select touch from block where idindagine = $::yacati::survey(idindagine) and iduser = $::yacati::user(id)"] > 0} { + #MOVE SQL + if {[yadb::getNumTuples $db "Select touch from log.block where proj = $::yacati::survey(proj) and uid = $::yacati::user(uid)"] > 0} { ::yalog::error "Error, are they trying to avoid pause block?" ::yatk_dlg::error [mc "Error, are you trying to avoid pause block?\n\nPlease call the administrator!!!"] return } - if {[::cati::check_user_connection $yacati::user(id) $yacati::survey(idindagine) $db_int] == 1} { + if {[::cati::check_user_connection $yacati::user(uid) $yacati::survey(proj) $db] == 1} { set tmp [yatk_dlg::continue [mc "Warning, your account is aleady connected, please contact the system administrator."]] if {$tmp == 1} { exit } } - array set ::yacati::session [::cati::getUserSession $db_sample $db_int [::yamisc::getIp] \ - $::yacati::user(id) $user_name $::yacati::survey(idindagine) $::yacati::survey(titolo)] + array set ::yacati::session [::cati::getUserSession $db [::yamisc::getIp] $::yacati::user(uid) \ + $user_name $::yacati::survey(proj) $::yacati::survey(name)] if {[array size ::yacati::session]==0} {return [::yatk_dlg::error [mc "Warning, you are not on any schedule!"]]} ::yacati::setWdjValue bbedit [regsub -all \\n $::yacati::user(note) ""] disabled - wm title . "yacati -- $::yacati::user(nome) $::yacati::user(cognome) ($user_name) @ $project" + wm title . "yacati -- $::yacati::user(name) $::yacati::user(surname) ($user_name) @ $project" ::yacati::configureWdj con_state state normal set wdj [::yacati::getWdj con_state] @@ -1320,7 +1316,7 @@ ::yacati::configureWdj bt_save state normal if { $::yacati::survey(freq_mon) != 0 } { - set ::yacati::perfIdxs [::cati::perfIdxCalc $db_sample $db_int $::yacati::survey(idindagine) $::yacati::session(inizio_turno) $::yacati::user(id)] + set ::yacati::perfIdxs [::cati::perfIdxCalc $db $::yacati::survey(proj) $::yacati::session(inizio_turno) $::yacati::user(uid)] } else { set ::yacati::perfIdxs [list 0.0 0.0 0.0 0.0] } @@ -1345,15 +1341,16 @@ set wdj [::yacati::getWdj work] $wdj delete list 0 end set i 0 - pg_select $db_sample "Select tipo_attivita from attivita " rec { - $wdj insert list $i $rec(tipo_attivita) + #MOVE SQL + pg_select $db "Select job from projects.jobs " rec { + $wdj insert list $i $rec(job) incr i } set wdj [::yacati::getWdj study] $wdj delete list 0 end set i 0 - pg_select $db_sample "Select titolo from titolo_studio" rec { + pg_select $db "Select study from projects.study_degrees" rec { $wdj insert list $i $rec(titolo) incr i } @@ -1368,50 +1365,50 @@ # and populate the GUI with its data # # @see ::cati::getContact ::cati::getAppointment -# @param db_sample the hw of the db sample -# @param db_int the hw of the db int +# @param db - db connection handler # @retrun 1 if we have a new contact, 0 otherwise -proc ::yacati::get_contact {db_sample db_int } { +proc ::yacati::get_contact {db} { array unset ::yacati::contact - array set ::yacati::contact [::cati::getContact $db_sample $db_int $yacati::user(id) [array get yacati::survey]] - array set survey [array get yacati::survey] + array set ::yacati::contact [::cati::getContact $db $yacati::user(uid) [array get yacati::survey]] + array set survey [array get ::yacati::survey] if {[array size ::yacati::contact]>0} { - set yacati::contact(s_activity) [cati::getSessionActivity $db_int $yacati::user(id) $survey(idindagine) $yacati::contact(com_sql) $yacati::contact(id)] - if { $yacati::contact(s_activity) == -1 } { - yalog::error "There's some nasty problem getSessionActivity returned -1" - yatk_dlg::error "There's some nasty problem getSessionActivity returned -1\nCall the administrator" + set yacati::contact(s_activity) [::cati::getSessionActivity $dbt $::yacati::user(uid) \ + $survey(proj) $::yacati::contact(com_sql) $::yacati::contact(rid)] + if { $::yacati::contact(s_activity) == -1 } { + ::yalog::error "There's some nasty problem getSessionActivity returned -1" + ::yatk_dlg::error "There's some nasty problem getSessionActivity returned -1\nCall the administrator" } - yalog::debug "Open session activity: $yacati::contact(s_activity)" - yalog::debug "Now i fill interface fields." - incr yacati::contact(tentativo) - set yacati::nome_usato 0 + ::yalog::debug "Open session activity: $yacati::contact(s_activity)" + ::yalog::debug "Now i fill interface fields." + incr ::yacati::contact(tentativo) + set ::yacati::nome_usato 0 - yacati::configureWdj ctel1 state normal - yacati::configureWdj ctel2 state normal + ::yacati::configureWdj ctel1 state normal + ::yacati::configureWdj ctel2 state normal - if { $yacati::contact(tel_disabled1) == 1 } { - yacati::configureWdj ctel1 state disabled - yacati::configureWdj tel1 disabledbackground black + if { $::yacati::contact(tel_disabled1) == 1 } { + ::yacati::configureWdj ctel1 state disabled + ::yacati::configureWdj tel1 disabledbackground black } - if { $yacati::contact(tel_disabled2) == 1 } { - yacati::configureWdj ctel2 state disabled - yacati::configureWdj tel2 disabledbackground black + if { $::yacati::contact(tel_disabled2) == 1 } { + ::yacati::configureWdj ctel2 state disabled + ::yacati::configureWdj tel2 disabledbackground black } - if { $yacati::contact(tel_attivo) == "" } { + if { $::yacati::contact(tel_attivo) == "" } { set ::yacati::CkTel 1 } else { set ::yacati::CkTel $yacati::contact(tel_attivo) } - yacati::setWdjValue company_name $yacati::contact(nome) disabled + ::yacati::setWdjValue company_name $yacati::contact(name) disabled - yacati::setWdjValue tel1 [string trim $yacati::contact(tel1)] disabled - yacati::setWdjValue tel2 [string trim $yacati::contact(tel2)] disabled - yacati::setWdjValue tel3 [string trim $yacati::contact(tel3)] normal - yacati::setWdjValue tel4 [string trim $yacati::contact(tel4)] normal + ::yacati::setWdjValue tel1 [string trim $yacati::contact(tel1)] disabled + ::yacati::setWdjValue tel2 [string trim $yacati::contact(tel2)] disabled + ::yacati::setWdjValue tel3 [string trim $yacati::contact(tel3)] normal + ::yacati::setWdjValue tel4 [string trim $yacati::contact(tel4)] normal if {[string length [string trim $yacati::contact(tel2)]]==0} {[::yacati::getWdj ctel2] configure -state disabled } @@ -1480,7 +1477,7 @@ # save a contact # # @return an array like the one of yacati::getOpEditData plus schedule history -proc ::yacati::prepareSave {idstato} { +proc ::yacati::prepareSave {ouid} { array set contact [array get ::yacati::contact] array set survey [array get ::yacati::survey] array set user [array get ::yacati::user] @@ -1498,13 +1495,13 @@ return [list err -2] } - if {$idstato==-1} { + if {$ouid==-1} { yalog::error "user choose an invalid contact state" return [list err -3] } set contact(note) [string trim $contact(note)] - set contact(note) "$contact(note) $contact(tentativo) [lindex $survey(statox) $idstato]\(tel$edata(active_phone),$user_name\) " + set contact(note) "$contact(note) $contact(tentativo) [lindex $survey(statox) $ouid]\(tel$edata(active_phone),$user_name\) " set lenNote [string length $contact(note)] if { $lenNote > 300 } { set contact(note) [string range $contact(note) [expr {$lenNote - 300}] end] @@ -1542,20 +1539,21 @@ return [array get ret] } -# Enable/Disable phone numbers on db_sample +# Enable/Disable phone numbers on db # -# @param db_sample sampling database connection handler -proc ::yacati::managePhones {db_sample} { +# @param db - db connection handler +proc ::yacati::managePhones {db} { + #MOVE SQL foreach phone $yacati::disabledPhones { - if { [yadb::execl $db_sample "update $yacati::survey(nome_tabella) set \ - tel_disabled$phone=1 WHERE id=$yacati::contact(id) and cod_com=$yacati::contact(com_sql)"] == -1} { + if { [yadb::execl $db "update projects.$yacati::survey(pjtable) set \ + tel_disabled$phone=1 WHERE rid=$yacati::contact(rid) and cod_com=$yacati::contact(com_sql)"] == -1} { yalog::error "failed to disable phone $phone" } } foreach phone $yacati::enabledPhones { - if { [yadb::execl $db_sample "update $yacati::survey(nome_tabella) set \ - tel_disabled$phone=0 WHERE id=$yacati::contact(id) and cod_com=$yacati::contact(com_sql)"] == -1} { + if { [yadb::execl $db "update projects.$yacati::survey(pjtable) set \ + tel_disabled$phone=0 WHERE rid=$yacati::contact(rid) and cod_com=$yacati::contact(com_sql)"] == -1} { yalog::error "failed to enable phone $phone" } } @@ -1798,22 +1796,22 @@ # Wrap around ::yaacs::sendfax # -# @param db_sample db handler for ::yacati::config(DB_SAMPLE) +# @param db - db connection handler # @param faxserver fax server ip # @param edata a list of data coming from GUI (necessary to send the fax) # @param percorso path to the shell script which generate fax cover dinamically # @return a list of 2 elems, the first is exit code (0 on success, -1 if something goes wrong) # the second is a describing string -proc ::yacati::sendFaxWrap { db_sample faxserver edata} { +proc ::yacati::sendFaxWrap { db faxserver edata} { array set survey [array get yacati::survey] array set contact [array get yacati::contact] array set user [array get yacati::user] array set mdata $edata - set home [yaconf::checkLocalConf] + set home [::yaconf::checkLocalConf] set cover "$home/spool/fax/cover_fax.ps" - if { [sendfax::init $faxserver $home] != -1 } { + if { [::sendfax::init $faxserver $home] != -1 } { regsub -all {[^0-9]} $mdata(fax) "" mdata(fax); if { $mdata(fax)=="" || $mdata(ref)=="" } { @@ -1821,21 +1819,21 @@ } else { - set qry_fax [yadb::getTuple $db_sample "Select commento_fax,percorso_fax from indagini where idindagine=$survey(idindagine)" 0] + set qry_fax [::yadb::getTuple $db "Select fax_path from projects.projects where proj=$survey(proj)" 0] set comm [lindex $qry_fax 0]; set percorso [lindex $qry_fax 1]; - if { [sendfax::createCover [string trim $percorso] $cover [string trim $mdata(fax)] \ - [string trim $mdata(ref)] $contact(tel1) [string trim $contact(nome)] $contact(adde) $contact(sett)] == -1 } { + if { [::sendfax::createCover [string trim $percorso] $cover [string trim $mdata(fax)] \ + [string trim $mdata(ref)] $contact(phone1) [string trim $contact(name)] $contact(employee) $contact(field)] == -1 } { return [list -1 [mc "Warning, you can not send any fax for this survey."]] } #add error handling... if anything goes wrong during fax sending! - if { [sendfax::send $mdata(fax) $user(login)] < 0 } { + if { [::sendfax::send $mdata(fax) $user(login)] < 0 } { return [list -1 [mc "Error, there's a problem while sending, chek your log."]] } - set sql "Insert into log_fax (fax,idindagine,idintervistatore,esito,idazienda,quando) values ('$mdata(fax)', $survey(idindagine), $user(id), True, $contact(id), now())"; - return [list [yadb::execl $db_sample $sql] "Ok"] + set sql "Insert into log.fax (fax,proj,uid,status,rid,touch) values ('$mdata(fax)', $survey(proj), $user(uid), true, $contact(rid), now())"; + return [list [::yadb::execl $db $sql] "Ok"] } } else { @@ -1845,7 +1843,7 @@ # Some kind of dialog window containg activity session's summary # -proc ::yacati::exitWindow {db_int db_sample reslist pj nc detect idpj} { +proc ::yacati::exitWindow {db reslist pj nc detect idpj} { #reslist contains 4 value # working hour in the current ending session @@ -1863,7 +1861,7 @@ set msgPause "No" - if {[::cati::crapOnExit $db_int $db_sample [lindex $reslist 1] $idpj]} { + if {[::cati::crapOnExit $db [lindex $reslist 1] $idpj]} { ::yalog::debug "A non clear end session detected" set ::yacati::boMsg "Something wrong happens during your session.Please write it down on your WORK FORM" } @@ -1989,7 +1987,7 @@ # Manage pause stuff. Check for max pause and # max sum pause constraints -proc ::yacati::managePause {db_sample db_int start_pause} { +proc ::yacati::managePause {db start_pause} { array set survey [array get ::yacati::survey] array set user [array get ::yacati::user] array set session [array get ::yacati::session] @@ -2020,7 +2018,7 @@ -command { ::yalog::debug "Operator wants to restart.Check for pause constraints..." if {$::yacati::bb_detect == 1} { - set howmany [::yadb::getNumTuples $db_int "Select touch from block where idindagine = $::yacati::survey(idindagine) and iduser = $::yacati::user(id)"]; + set howmany [::yadb::getNumTuples $db "Select touch from log.block where proj = $::yacati::survey(proj) and uid = $::yacati::user(uid)"]; if {$howmany == 0} { set ::yacati::bb_detect 0 set ::yacati::init_pausa 0 @@ -2034,15 +2032,16 @@ if {($::yacati::survey(max_pause)!=0)} { if {$::yacati::bb_detect==0} { #check for constraints only the first time - set ::yacati::bb_detect [::cati::checkPauseConstraints $db_sample $db_int $yacati::user(id) $::yacati::survey(idindagine) \ + set ::yacati::bb_detect [::cati::checkPauseConstraints $db $yacati::user(uid) $::yacati::survey(proj) \ $yacati::survey(max_pause) $yacati::survey(sum_pause) $yacati::ckStartPause] } if {$::yacati::bb_detect==0} { set ::yacati::ckPauseVar 1 } else { set ::yacati::have_you_ever_be_detected 1 - set pause_duration [lindex [::yadb::getTuple $db_int "select date_trunc('second',(now()::time - '$::yacati::ckStartPause'::time))" 0] 0] - set time_is_now [lindex [::yadb::getTimeSec $db_sample] 1] + #use the brand new TIME LIBRARY here + set pause_duration [lindex [::yadb::getTuple $db "select date_trunc('second',(now()::time - '$::yacati::ckStartPause'::time))" 0] 0] + set time_is_now [lindex [::yadb::getTimeSec $db] 1] .ckpause.status configure -foreground red -text [mc "Pause exceed!\nYour pause was %s long" $pause_duration] update ::yatk_wm::center .ckpause . @@ -2117,15 +2116,15 @@ proc ::yacati::callBack {db pj start stop com contact_a} { package require Iwidgets - set ::tk::male 0 - set ::tk::female 0 - set ::tk::myId $pj - set ::tk::myStart $start - set ::tk::myStop $stop - set ::tk::myCom $com - set ::tk::myDb $db + set ::yacati::cb_male 0 + set ::yacati::cb_female 0 + set ::yacati::cb_proj $pj + set ::yacati::cb_myStart $start + set ::yacati::cb_myStop $stop + set ::yacati::cb_myCom $com + set ::yacati::cb_myDb $db - array set ::tk::myData [list] + array set ::yacati::bc_myData [list] array set contact $contact_a catch {destroy .newapp} @@ -2187,18 +2186,17 @@ if {[info exists contact(sexapp)]} { switch $contact(sexapp) { - "M" { set ::tk::male 1; set ::tk::female 0; } - "F" { set ::tk::male 0; set ::tk::female 1; } + "M" { set ::yacati::bc_male 1; set ::yacati::bc_female 0; } + "F" { set ::yacati::bc_male 0; set ::yacati::bc_female 1; } } } - checkbutton .newapp.cbmale -text [mc "Male"] -variable ::tk::male -command {set ::tk::male 1; set ::tk::female 0;} - checkbutton .newapp.cbfemale -text [mc "Female"] -variable ::tk::female -command {set ::tk::male 0; set ::tk::female 1;} + checkbutton .newapp.cbmale -text [mc "Male"] -variable ::yacati::bc_male -command {set ::yacati::bc_male 1; set ::yacati::bc_female 0;} + checkbutton .newapp.cbfemale -text [mc "Female"] -variable ::yacati::bc_female -command {set ::yacati::bc_male 0; set ::yacati::bc_female 1;} button .newapp.ok -image $::yatk_icons::ok -text [mc "Ok"] -compound left \ -command { - set inizio_pj $::tk::myStart - set fine_pj $::tk::myStop - set id_int $::tk::myId + set inizio_pj $::yacati::bc_myStart + set fine_pj $::yacati::bc_myStop set date_app [.newapp.date get] set mese [string range $date_app 0 1] @@ -2218,14 +2216,11 @@ return } - # tutto questo codice e' dipendente dal formato - # della data di postgresql, ISO in questo caso - # per essere sicuri che non ci siano mal funzionamenti - # mettere almeno set datestyle to iso - # prima di questo blocco + # the following bloxk is ISO datestyle dependant + #anyway use TIME LIBRARY please set zone_sql "select -date_part('timezone', now());" - set res [yadb::getTuple $::tk::myDb $zone_sql 0] + set res [yadb::getTuple $::yacati::bc_myDb $zone_sql 0] set zone [lindex $res 0] set zone [expr $zone/3600] @@ -2249,10 +2244,10 @@ set date_setted "$anno-$mese-$giorno" set sql_chk "select date_cmp ('$date_setted'::date, date(now()))" - set chkdd [lindex [yadb::getTuple $::tk::myDb $sql_chk 0] 0] + set chkdd [lindex [yadb::getTuple $::yacati::bc_myDb $sql_chk 0] 0] set sql_chk "select time_cmp ('$time_setted'::time, now()::time)" - set chktt [lindex [yadb::getTuple $::tk::myDb $sql_chk 0] 0] + set chktt [lindex [yadb::getTuple $::yacati::bc_myDb $sql_chk 0] 0] if {(($chkdd < 0) || (($chkdd == 0) && ($chktt < 0)))} { yatk_dlg::error [mc "Invalid date and/or time: They refer to past date."] @@ -2260,7 +2255,7 @@ } set sql_chk "select date_cmp ('$date_setted'::date, '$inizio_pj'::date)" - set re [lindex [yadb::getTuple $::tk::myDb $sql_chk 0] 0] + set re [lindex [yadb::getTuple $::yacati::bc_myDb $sql_chk 0] 0] if { $re < 0 } { yatk_dlg::error [mc "Invalid date: appointment exced survey date limits.\n$inizio_pj-$fine_pj"] @@ -2268,7 +2263,7 @@ } set sql_chk "select date_cmp ('$date_setted'::date, '$fine_pj'::date)" - set re [lindex [yadb::getTuple $::tk::myDb $sql_chk 0] 0] + set re [lindex [yadb::getTuple $::yacati::bc_myDb $sql_chk 0] 0] if { $re > 0 } { yatk_dlg::error [mc "Invalid date: appointment exced appointment limits.\n$inizio_pj-$fine_pj"] @@ -2276,21 +2271,21 @@ } set bounded 0 - - pg_select $::tk::myDb "select idturno from tuind where idindagine=$id_int and giorno='$date_setted'::date" rec { + #MOVE SQL to a proper place + pg_select $::yacati::bc_myDb "select idt from log.tupjs where proj=$::yacati::bc_proj and giorno='$date_setted'::date" rec { if { ("$rec(idturno)" == "") } { set bounded 0 break } - set sql_bound "select inizio,fine from turni where idturno=$rec(idturno)" - set res [yadb::getTuple $::tk::myDb $sql_bound 0] + set sql_bound "select tstart,tend from turns where idt=$rec(idt)" + set res [yadb::getTuple $::yacati::bc_myDb $sql_bound 0] set i [lindex $res 0] set f [lindex $res 1] - set ci [lindex [yadb::getTuple $::tk::myDb "select time_cmp ('$time_setted'::time, '$i'::time)" 0] 0] + set ci [lindex [yadb::getTuple $::yacati::bc_myDb "select time_cmp ('$time_setted'::time, '$i'::time)" 0] 0] - set cf [lindex [yadb::getTuple $::tk::myDb "select time_cmp ('$time_setted'::time, '$f'::time)" 0] 0] + set cf [lindex [yadb::getTuple $::yacati::bc_myDb "select time_cmp ('$time_setted'::time, '$f'::time)" 0] 0] if {(($ci >= 0) && ($cf<=0))} { set bounded 1 @@ -2317,14 +2312,14 @@ } set sexapp "" - if { $::tk::male == 1 } { + if { $::yacati::bc_male == 1 } { set sexapp "M" } - if { $::tk::female == 1 } { + if { $::yacati::bc_female == 1 } { set sexapp "F" } - if { $::tk::myCom == "f" && ($annoapp == "" || $nomeapp == "" || $sexapp == "") } { + if { $::yacati::bc_myCom == "f" && ($annoapp == "" || $nomeapp == "" || $sexapp == "") } { yatk_dlg::error [mc "You must provide contact's anagraphics data to book \ a call back. Retry and fill in all the fields!"] return @@ -2354,7 +2349,7 @@ set ret(nomeapp) $nomeapp set ret(annoapp) $annoapp set ret(sexapp) $sexapp - array set ::tk::myData [array get ret] + array set ::yacati::bc_myData [array get ret] set ::yacati::callBackButton 1 } else { return @@ -2391,16 +2386,16 @@ if {$grab != ""} {grab $grab} update idletasks - array set myRet [array get ::tk::myData] + array set myRet [array get ::yacati::bc_myData] - unset ::tk::male - unset ::tk::female - unset ::tk::myId - unset ::tk::myStart - unset ::tk::myStop - unset ::tk::myDb - unset ::tk::myCom - unset ::tk::myData + unset ::yacati::bc_male + unset ::yacati::bc_female + unset ::yacati::bc_proj + unset ::yacati::bc_myStart + unset ::yacati::bc_myStop + unset ::yacati::bc_myDb + unset ::yacati::bc_myCom + unset ::yacati::bc_myData unset ::yacati::callBackButton return [array get myRet] @@ -2595,56 +2590,37 @@ ## # Init db packages yalog::message "Connecting to db..." -set db_int [::yadb::connect $yacati::config(DB_INT) $yacati::config(HOST_INT) $yacati::config(USER_INT) $yacati::config(PORT_INT)] -set db_sample [::yadb::connect $yacati::config(DB_SAMPLE) $yacati::config(HOST_SAMPLE) $yacati::config(USER_SAMPLE) $yacati::config(PORT_SAMPLE)] -if {($db_int==-1) || ($db_sample==-1)} { +set db [::yadb::connect $yacati::config(DB) $yacati::config(HOST) $yacati::config(USER) $yacati::config(PORT)] +if {$db==-1} { yatk_dlg::error [mc "Cannot connect to dbs please check your conf"] exit } ## # Setting up connection loss problem -set loss_sample { - yalog::debug "Connection loss occurs on $yacati::config(DB_SAMPLE)" - yadb::disconnect $db_sample; - set db_sample [yadb::connect $yacati::config(DB_SAMPLE) $yacati::config(HOST_SAMPLE) $yacati::config(USER_SAMPLE) $yacati::config(PORT_SAMPLE)]; - if {$db_sample == -1} { - yalog::debug "After a connection loss on $yacati::config(DB_SAMPLE) we're not able to riconnect. exit now!" +set loss { + yalog::debug "Connection loss occurs on $yacati::config(DB)" + yadb::disconnect $db; + set db [yadb::connect $yacati::config(DB) $yacati::config(HOST) $yacati::config(USER) $yacati::config(PORT)]; + if {$db == -1} { + yalog::debug "After a connection loss on $yacati::config(DB) we're not able to riconnect. exit now!" ::yatk_dlg::error [mc "After a connection loss we're not able to re-connect to the db server.\n\ Please check your net device aviability or the status of your db server.\n\n\ It's safer exit now!"] exit } - yadb::onConnectionLoss $db_sample $loss_sample - yalog::debug "After a connection loss on $yacati::config(DB_SAMPLE) we're able to riconnect!" + yadb::onConnectionLoss $db $loss + yalog::debug "After a connection loss on $yacati::config(DB) we're able to riconnect!" ::yatk_dlg::info [mc "An unexpected loss of connection to the database occurs,\n\n\ Now you're reconnect to db but check if everithing is ok"] } -set loss_int { - yalog::debug "Connection loss occurs on $yacati::config(DB_INT)" - yadb::disconnect $db_int; - set db_int [yadb::connect $yacati::config(DB_INT) $yacati::config(HOST_INT) $yacati::config(USER_INT) $yacati::config(PORT_INT)]; - if {$db_int == -1} { - yalog::debug "After a connection loss on $yacati::config(DB_INT) we're not able to riconnect. exit now!" - ::yatk_dlg::error [mc "After a connection loss we're not able to re-connect to the db server.\n\ - Please check your net device aviability or the status of your db server.\n\n\ - It's safer exit now!"] - exit - } - yadb::onConnectionLoss $db_int $loss_int - yalog::debug "After a connection loss on $yacati::config(DB_INT) we're able to riconnect!" - ::yatk_dlg::info [mc "An unexpected loss of connection to the database occurs.\n\ - Now you're reconnect to db but check if everithing is ok"] -} +yadb::onConnectionLoss $db $loss -yadb::onConnectionLoss $db_sample $loss_sample -yadb::onConnectionLoss $db_int $loss_int - ## # Setting autodial yalog::message "Setting Autodialing..." -set yacati::autodial [::yavoip::getAutodial $db_int [array get ::yacati::config]] +set yacati::autodial [::yavoip::getAutodial $db [array get ::yacati::config]] if {$yacati::autodial==1 && [::yavoip::conn [array get ::yacati::config]]==-1} { ::yalog::error "Somethig goes wrong while connetting to the VoIP server" ::yatk_dlg::info "Cannot connect to the VoIP server, the session \ @@ -2664,7 +2640,7 @@ if { $gettedopts(p) != "" } { yalog::message "Starting with survey $gettedopts(p)" - yacati::openSurvey $db_sample $db_int $gettedopts(p) + ::yacati::openSurvey $db $gettedopts(p) } Modified: trunk/yadmin.tcl =================================================================== --- trunk/yadmin.tcl 2006-04-03 23:39:28 UTC (rev 609) +++ trunk/yadmin.tcl 2006-04-03 23:45:34 UTC (rev 610) @@ -126,7 +126,7 @@ #default settings -::yalog::setFile [yaconf::getLogFile] +::yalog::setFile [::yaconf::getLogFile] ::yalog::setLevel error set ::yadmin::logLevel error @@ -150,7 +150,7 @@ # handle the "exitY" wm event -wm protocol . WM_DELETE_WINDOW {::yadmin::exitY $db_sample $db_int} +wm protocol . WM_DELETE_WINDOW {::yadmin::exitY $db} # a "title" @@ -164,14 +164,14 @@ menu .mbar.mfile -tearoff 0 .mbar.mfile add command -image $::yatk_icons::open -label [mc "Open"] -compound left \ - -command {::yadmin::connect $db_sample $db_int} -accelerator <Ctrl-F> + -command {::yadmin::connect $db} -accelerator <Ctrl-F> .mbar.mfile add command -image $::yatk_icons::refresh -label [mc "Reload"] -compound left \ - -command {::yadmin::reload $db_sample $db_int} -accelerator <Ctrl-R> + -command {::yadmin::reload $db} -accelerator <Ctrl-R> .mbar.mfile add command -label [mc "Preferences..."] -command {::yadmin::preferences} .mbar.mfile add command -image $::yatk_icons::disco -label [mc "Disconnect"] -compound left \ -command {::yadmin::disconnect} .mbar.mfile add command -image $::yatk_icons::exit -label [mc "Exit"] -compound left \ - -command {::yadmin::exitY $db_sample $db_int} -accelerator <Ctrl-X> + -command {::yadmin::exitY $db} -accelerator <Ctrl-X> # project menu definition @@ -180,14 +180,14 @@ # project's sub-menues menu .mbar.mpj.statmgmt -tearoff 0 -.mbar.mpj.statmgmt add command -label [mc "Flush..."] -command {::yadmin::flushPj $db_sample $db_int} -.mbar.mpj.statmgmt add command -label [mc "Flush for this project"] -command {::yadmin::flushPj $db_sample $db_int $yadmin::pj} +.mbar.mpj.statmgmt add command -label [mc "Flush..."] -command {::yadmin::flushPj $db} +.mbar.mpj.statmgmt add command -label [mc "Flush for this project"] -command {::yadmin::flushPj $db $yadmin::pj} .mbar.mpj add command -image $::yatk_icons::new -label [mc "New"] -compound left \ - -command {::yadmin::editPj $db_sample $db_int} + -command {::yadmin::editPj $db} .mbar.mpj add command -label [mc "Edit..."] -command { - set pjList [::cati::getProjList $db_sample 0] + set pjList [::cati::getProjList $db 0] if {$pjList == -1} { ::yatk_dlg::error [mc "Unable to open a project."] @@ -196,7 +196,7 @@ set altText [mc "Show all projects"] - set pjActList [::cati::getProjList $db_sample 1] + set pjActList [::cati::getProjList $db 1] if {$pjActList == -1} { ::yatk_dlg::error [mc "Unable to open a project."] return @@ -212,22 +212,22 @@ if { !$retval } {return} if {$pjName == ""} {::yatk_dlg::error [mc "You must select a project."]; return} - array set survey [::cati::getSurveyFromTitle $db_sample $pjName] - set idPj $survey(idindagine) + array set survey [::cati::getSurveyFromTitle $db $pjName] + set idPj $survey(proj) unset pjName - yadmin::editPj $db_sample $db_int $idPj + ::yadmin::editPj $db $idPj } .mbar.mpj add command -image $::yatk_icons::edit -label [mc "Edit this project"] -compound left \ - -command {::yadmin::editPj $db_sample $db_int $::yadmin::pj} -.mbar.mpj add command -label [mc "Remove..."] -command {::yadmin::remove $db_sample} + -command {::yadmin::editPj $db $::yadmin::pj} +.mbar.mpj add command -label [mc "Remove..."] -command {::yadmin::remove $db} .mbar.mpj add separator -.mbar.mpj add command -label [mc "Turns definition"] -command {::yadmin::turnDef $db_sample} +.mbar.mpj add command -label [mc "Turns definition"] -command {::yadmin::turnDef $db} .mbar.mpj add separator -.mbar.mpj add command -label [mc "Massive fax..."] -command {::yadmin::massiveFax $db_sample $::yadmin::config(FAX_SERVER)} -.mbar.mpj add command -label [mc "Massive mail..."] -command {::yadmin::massiveMail $db_sample $::yadmin::config(MAIL_SERVER) \ +.mbar.mpj add command -label [mc "Massive fax..."] -command {::yadmin::massiveFax $db $::yadmin::config(FAX_SERVER)} +.mbar.mpj add command -label [mc "Massive mail..."] -command {::yadmin::massiveMail $db $::yadmin::config(MAIL_SERVER) \ $::yadmin::config(MAIL_SENDER)} .mbar.mpj add separator .mbar.mpj add cascade -label [mc "Stats managment"] -menu .mbar.mpj.statmgmt @@ -236,9 +236,9 @@ menu .mbar.msample -tearoff 0 .mbar.msample add command -image $::yatk_icons::sample -label [mc "Sample..."] -compound left \ - -command {::yadmin::doSample $db_sample $db_int $yadmin::pj} -.mbar.msample add command -label [mc "Re-populate sub universe..."] -command {::yadmin::doSampleUni $db_sample} -.mbar.msample add command -label [mc "Re-popoulate by municipality..."] -command {::yadmin::doSampleUniCom $db_sample} + -command {::yadmin::doSample $db $yadmin::pj} +.mbar.msample add command -label [mc "Re-populate sub universe..."] -command {::yadmin::doSampleUni $db} +.mbar.msample add command -label [mc "Re-popoulate by municipality..."] -command {::yadmin::doSampleUniCom $db} # quota menu definition @@ -247,12 +247,12 @@ menu .mbar.mquota.geo -tearoff 0 .mbar.mquota add cascade -label [mc "Geographical"] -menu .mbar.mquota.geo -.mbar.mquota.geo add command -label [mc "Done"] -command {::yadmin::quotaCheck $db_sample $::yadmin::pj 0} -.mbar.mquota.geo add command -label [mc "Distance"] -command {::yadmin::quotaCheck $db_sample $yadmin::pj 1} +.mbar.mquota.geo add command -label [mc "Done"] -command {::yadmin::quotaCheck $db $::yadmin::pj 0} +.mbar.mquota.geo add command -label [mc "Distance"] -command {::yadmin::quotaCheck $db $yadmin::pj 1} .mbar.mquota add command -label [mc "Gender - Age"] -command { set ::yadmin::cage [::yadmin::cageGet] - ::yadmin::quotaCheck $db_sample $::yadmin::pj 2 + ::yadmin::quotaCheck $db $::yadmin::pj 2 } .mbar.mquota add separator @@ -261,17 +261,17 @@ # bbtools menu definition menu .mbar.mbbt -tearoff 0 -.mbar.mbbt add command -label [mc "Block..."] -command {::yadmin::doBbTools $db_sample \ +.mbar.mbbt add command -label [mc "Block..."] -command {::yadmin::doBbTools $db \ "" $gettedopts(c) $::yadmin::logLevel} .mbar.mbbt add command -image $::yatk_icons::bbt -label [mc "Block for this project"] -compound left \ - -command {::yadmin::doBbTools $db_sample \ + -command {::yadmin::doBbTools $db \ $yadmin::pj $gettedopts(c) $::yadmin::logLevel} # operators menu menu .mbar.mops -tearoff 0 .mbar.mops add command -image $::yatk_icons::hours -label [mc "Working hours report"] -compound left \ - -command {::yadmin::workingHoursReport $db_int $yadmin::pj} + -command {::yadmin::workingHoursReport $db $yadmin::pj} # add all menus to the bar @@ -365,7 +365,7 @@ label .fperf.activecomp -text [mc "active operators"] label .fperf.edactivecomp -relief groove -text "" -width 5 -anchor w -button .fperf.sett -text "..." -command {if {[yadmin::perfsett $db_sample] == 0} {yadmin::reload $db_sample $db_int}} +button .fperf.sett -text "..." -command {if {[yadmin::perfsett $db] == 0} {yadmin::reload $db}} grid .fperf.comp .fperf.edcomp .fperf.refu .fperf.edrefu \ .fperf.call .fperf.edcall .fperf.oth .fperf.edoth \ @@ -383,7 +383,7 @@ label .fquota.title -text "" button .fquota.refresh -image $::yatk_icons::refresh -text [mc "refresh"] -compound left \ - -relief groove -command {::yadmin::quotaCheck $db_sample $::yadmin::pj $::yadmin::qType} + -relief groove -command {::yadmin::quotaCheck $db $::yadmin::pj $::yadmin::qType} scrollbar .fquota.sbquota -bd 0 -orient vertical -command {.fquota.quotatab yview} table .fquota.quotatab -cols 3 -colstretchmode all \ -colwidth 20 -height 10 \ @@ -415,7 +415,7 @@ #bindings -bind . <Control-KeyPress> {::yadmin::bindings %K $db_sample $db_int} +bind . <Control-KeyPress> {::yadmin::bindings %K $db} # UTILITY procs @@ -424,13 +424,13 @@ # menu commands, see accelerators) # # @param char - char pressed after Alt -proc ::yadmin::bindings {char db_sample db_int} { +proc ::yadmi... [truncated message content] |