|
From: <bu...@us...> - 2006-04-04 10:37:14
|
Revision: 611 Author: bugant Date: 2006-04-04 03:36:58 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=611&view=rev Log Message: ----------- * use only one db; * fix find comboboxes fill-in when no users has been inserted on the db; * fix a bug on ::yacco::addOpTy which affect the 'update' mode: selection was re-checked on updating so if you lost it an error occurs and obviously this's a no-sense. * fix all op(<field-name>) values; * rename cellphone to mobile; * some new todos; Modified Paths: -------------- trunk/dbyaacs/interviewers.sql trunk/docs/TODO trunk/yaacs/op.tcl trunk/yacco.tcl Modified: trunk/dbyaacs/interviewers.sql =================================================================== --- trunk/dbyaacs/interviewers.sql 2006-04-03 23:45:34 UTC (rev 610) +++ trunk/dbyaacs/interviewers.sql 2006-04-04 10:36:58 UTC (rev 611) @@ -79,7 +79,7 @@ surname character varying(25), cod_fiscale character(16) NOT NULL, address character varying(40), - cellphone character varying(15), + mobile character varying(15), email character varying(30), phone1 character varying(15), phone2 character varying(15), Modified: trunk/docs/TODO =================================================================== --- trunk/docs/TODO 2006-04-03 23:45:34 UTC (rev 610) +++ trunk/docs/TODO 2006-04-04 10:36:58 UTC (rev 611) @@ -18,7 +18,10 @@ * deb package for debian* (e.g. ubuntu) * manage error handling during ftp hylafax session * write Startkit documentation for windows - + * ::yacco::findCombo has a very poor and BAD DESIGN so + has to be fixed ;) + * yacco uses db and ::yacco::db as db handlers to the + same handler... fix it DONE: * yacati - reduce info on the final dialog we have to show only Modified: trunk/yaacs/op.tcl =================================================================== --- trunk/yaacs/op.tcl 2006-04-03 23:45:34 UTC (rev 610) +++ trunk/yaacs/op.tcl 2006-04-04 10:36:58 UTC (rev 611) @@ -306,7 +306,7 @@ if {$action == "create" || $action == "update"} { # put interviewers into it - set sqlRec "select (i.name || ' ' || i.surname) as name, i.cellphone as mobile, i.phone1 as phone1, \ + set sqlRec "select (i.name || ' ' || i.surname) as name, i.mobile as mobile, i.phone1 as phone1, \ i.phone2 as phone2, i.uid as uid, random() as rand, i.score as points from interviewers.interviewers i, interviewers.availability d \ where i.cod_fiscale=d.cod_fiscale and i.active='true' and d.available_from <= '$projStart'::date \ and i.int_type='$type'" @@ -451,8 +451,8 @@ # an empty array is returned on error. proc ::op::getIntTypes {db} { array set ret [list] - set sql "select id, type_desc from int_type" - set cmd {set ret($rec(id)) $rec(type_desc)} + set sql "select int_type, type_desc from interviewers.int_type" + set cmd {set ret($rec(int_type)) $rec(type_desc)} if {[::yadb::pgSelect $db $sql rec $cmd] < 0} { ::yalog::error "cannot get interviewers' available types" return [list] @@ -465,15 +465,15 @@ # @param db (op) database connection handler # @return return 0 on success; -1 on error. proc ::op::addIntType {db newType} { - return [::yadb::execl $db "insert into int_type(type_desc) values('$newType')"] + return [::yadb::execl $db "insert into interviewers.int_type(type_desc) values('$newType')"] } proc ::op::updateIntType {db id type} { - return [::yadb::execl $db "update int_type set type_desc='$type' where int_type=$id"] + return [::yadb::execl $db "update interviewers.int_type set type_desc='$type' where int_type=$id"] } proc ::op::delIntType {db id} { - return [::yadb::execl $db "delete from int_type where int_type=$id"] + return [::yadb::execl $db "delete from interviewers.int_type where int_type=$id"] } # update note field for a user. @@ -541,7 +541,7 @@ } if {$mode == 0} { set sqlOp "update interviewers.interviewers set name='$name', surname='$surname', address='$address', \ - city='$city', cap='$cap', phone1='$phone1', phone2='$phone2', cellphone='$cell', \ + city='$city', cap='$cap', phone1='$phone1', phone2='$phone2', mobile='$cell', \ email='$email', bplace='$bplace', bdate='$bdate', active=$active, note='$notes', \ score='$points', res_address='$alt_addr', res_city='$alt_city', res_cap='$alt_cap', \ sex='$sex', int_type='$type', cod_fiscale='$code', h_salary=$salary where login='$login'" @@ -554,13 +554,13 @@ evening=$evening, available_from='$availablefrom' where cod_fiscale='$code'" } else { set sqlOp "insert into interviewers.interviewers (name, surname, address, city, cap, phone1, phone2, \ - cellphone, email, cod_fiscale, bplace, bdate, active, note, score, res_address, res_city,\ + mobile, email, cod_fiscale, bplace, bdate, active, note, score, res_address, res_city,\ res_cap, sex, int_type, login, h_salary) values ( \ '$name', '$surname', '$address', '$city', '$cap', '$phone1', '$phone2', '$cell', '$email', \ '$code', '$bplace', '$bdate', '$active', '$notes', '$points', '$alt_addr', '$alt_city', \ '$alt_cap', '$sex', '$type', '$login', '$salary')" - set sqlBank "insert into nterviewers.banking_coordinates (bank, address, city, cod_abi, cod_cab, \ + set sqlBank "insert into interviewers.banking_coordinates (bank, address, city, cod_abi, cod_cab, \ checking_account, owner, cod_fiscale) values ( \ '$bank', '$bank_addr', '$bank_city', '$bank_abi', '$bank_cab', '$bank_cc', '$bank_owner', \ '$code')" @@ -593,7 +593,7 @@ if {$mode == 1} { array set op [::op::getOp $db $code] if {[::yadb::execl $db "insert into interviewers.interviewers_usync (cod_fiscale,uid,login,op)\ - values ('$code', $op(id), '$login', 0)"] == -1} { + values ('$code', $op(uid), '$login', 0)"] == -1} { yalog::error "cannot insert operator on intervistatori_usync" set ::op::err $::op::ERR_INSLOGIN return -1 Modified: trunk/yacco.tcl =================================================================== --- trunk/yacco.tcl 2006-04-03 23:45:34 UTC (rev 610) +++ trunk/yacco.tcl 2006-04-04 10:36:58 UTC (rev 611) @@ -116,10 +116,10 @@ label $ifr.lbbplace -text [mc "Bitrh place"] entry $ifr.bplace -validate key -validatecommand {::yacco::onValidateString %P %W} label $ifr.lbcf -text [mc "Cod. Fisc."] -button $ifr.btcf -text [mc "Cod. Fisc."] -command {::yacco::onPressCodFis $db_int} -takefocus 0 \ +button $ifr.btcf -text [mc "Cod. Fisc."] -command {::yacco::onPressCodFis $db} -takefocus 0 \ -image $::yatk_icons::hours -compound left entry $ifr.cf -takefocus { - ::yacco::onPressCodFis $db_int + ::yacco::onPressCodFis $db } label $ifr.lblogin -text [mc "Login"] @@ -213,9 +213,9 @@ label $pg_note.lbactive -text [mc "Activity status"] label $pg_note.status -radiobutton $pg_note.active -variable ::yacco::CkActive -value 0 -text [mc "Enable"] \ +radiobutton $pg_note.active -variable ::yacco::CkActive -value 1 -text [mc "Enable"] \ -command {$pg_note.status configure -image $::yatk_icons::enable} -radiobutton $pg_note.disable -variable ::yacco::CkActive -value 1 -text [mc "Disable"] \ +radiobutton $pg_note.disable -variable ::yacco::CkActive -value 0 -text [mc "Disable"] \ -command {$pg_note.status configure -image $::yatk_icons::disable} label $pg_note.lbpoints -text [mc "Points"] @@ -281,9 +281,9 @@ # ACTION buttons set ba [frame $info.l] button $ba.sms -text [mc "Sms"] -image $::yatk_icons::sms -compound top \ - -relief flat -command {::yacco::onPressSms $db_int} + -relief flat -command {::yacco::onPressSms $db} button $ba.link -text [mc "Link"] -image $::yatk_icons::link -compound top \ - -relief flat -command {::yacco::onPressLink $db_sample $db_int} + -relief flat -command {::yacco::onPressLink $db} button $ba.resetpwd -text [mc "Reset Pwd"] -image $::yatk_icons::rpwd -compound top \ -relief flat -command { set userto [string trim [[::yacco::getWdj "login"] get]] @@ -329,16 +329,16 @@ return } - ::yacco::onPressInvoice $db_int $::yacco::config(A2PS_CMD) + ::yacco::onPressInvoice $db $::yacco::config(A2PS_CMD) } grid $bp.conv $bp.rit -padx 3 -pady 3 set bc [frame $info.bts] button $bc.save -text [mc "Save"] -image $::yatk_icons::save -compound left \ - -command { yacco::onPressSave $db_int } + -command { yacco::onPressSave $db } button $bc.delete -text [mc "Delete"] -image $::yatk_icons::delete -compound left \ - -command {::yacco::onPressDelete $db_int} + -command {::yacco::onPressDelete $db} grid $bc.delete $bc.save -sticky se -padx 3 -pady 3 grid $ba $bp -sticky nw -padx 6 -pady 6 @@ -348,16 +348,16 @@ #Create "general action" buttons (right side of the window) set bts [frame .bts] button $bts.find -text [mc "Find"] -image $::yatk_icons::find -compound left \ - -command {::yacco::onPressFind $db_int} + -command {::yacco::onPressFind $db} button $bts.new -text [mc "New"] -image $::yatk_icons::new22 -compound left \ -command yacco::onPressNew button $bts.opst -image $::yatk_icons::optypes -text [mc "Operator Types"] \ -compound left -command {::yacco::configOpst} button $bts.usync -text [mc "Sync user"] -image $::yatk_icons::usync -compound left\ -command {if {[info exists ::yacco::config(REMOTE_USER)]} { - ::yacco::onPressUsync $db_int $::yacco::config(REMOTE_HOST) $::yacco::config(REMOTE_USER) + ::yacco::onPressUsync $db $::yacco::config(REMOTE_HOST) $::yacco::config(REMOTE_USER) } else { - ::yacco::onPressUsync $db_int $::yacco::config(REMOTE_HOST) + ::yacco::onPressUsync $db $::yacco::config(REMOTE_HOST) } } button $bts.settings -text [mc "Settings"] -image $::yatk_icons::control -compound left \ @@ -499,7 +499,7 @@ # Wdjs events # trigged when the user press button Find -proc ::yacco::onPressFind {db_int} { +proc ::yacco::onPressFind {db} { catch {destroy .pj} set focus [focus] set grab [grab current .] @@ -527,8 +527,8 @@ set surn [.fnd.fr.sur get] # build a list with field's name and value. - set fndList [list "cognome" $surn] - ::yacco::findCombo $db_int $fndList + set fndList [list "surname" $surn] + ::yacco::findCombo $db $fndList # display on the entry the first element # of the options' list if {[string trim [.fnd.fr.sur get]] != ""} { @@ -543,9 +543,12 @@ bind [.fnd.fr.sur component entry] <KeyRelease> "::yacco::ourCompletition %W %K {$completition}" set idx 0 - foreach c [::op::getInfos $db_int "cognome" 1] { - .fnd.fr.sur insert list $idx $c - incr idx + set surnames [::op::getInfos $db "surname" 1] + if {$surnames != -1} { + foreach c $surnames { + .fnd.fr.sur insert list $idx $c + incr idx + } } # name @@ -556,8 +559,8 @@ .fnd.fr.cod delete entry 0 end set name [.fnd.fr.nam get] # build a list with field's name and value. - set fndList [list "nome" $name] - yacco::findCombo $db_int $fndList + set fndList [list "name" $name] + yacco::findCombo $db $fndList # display on the entry the first element # of the options' list if {[string trim [.fnd.fr.nam get]] != ""} { @@ -572,9 +575,12 @@ bind [.fnd.fr.nam component entry] <KeyRelease> "::yacco::ourCompletition %W %K {$completition}" set idx 0 - foreach c [::op::getInfos $db_int "nome" 1] { - .fnd.fr.nam insert list $idx $c - incr idx + set names [::op::getInfos $db "name" 1] + if {$names != -1} { + foreach c $names { + .fnd.fr.nam insert list $idx $c + incr idx + } } # cod. fisc. @@ -585,7 +591,7 @@ set codi [.fnd.fr.cod get] # build a list with field's name and value. set fndList [list "cod_fiscale" $codi] - yacco::findCombo $db_int $fndList + yacco::findCombo $db $fndList } [.fnd.fr.cod component arrowBtn] configure -takefocus 0 @@ -593,9 +599,12 @@ bind [.fnd.fr.cod component entry] <FocusOut> [.fnd.fr.cod cget -selectioncommand] set idx 0 - foreach c [::op::getInfos $db_int "cod_fiscale"] { - .fnd.fr.cod insert list $idx $c - incr idx + set cods [::op::getInfos $db "cod_fiscale"] + if {$cods != -1} { + foreach c $cods { + .fnd.fr.cod insert list $idx $c + incr idx + } } grid .fnd.fr.surLbl .fnd.fr.sur -padx [list 5 0] -pady [list 5 0] -sticky nws @@ -610,7 +619,7 @@ set codFisc [.fnd.fr.cod get] set yacco::is_new_contact 0 ::yacco::set_editfields_state normal - if {[::yacco::fillInData $db_int $codFisc] != -1} { + if {[::yacco::fillInData $db $codFisc] != -1} { ::yacco::update_status edit set ::yacco::fButton 1 } @@ -809,7 +818,7 @@ return } - set pjLinked [::op::userPjs $dbs $opData(id)] + set pjLinked [::op::userPjs $dbs $opData(uid)] if {$pjLinked == -1} { ::yacco::dbError return @@ -821,7 +830,7 @@ [mc "Unlinked projects"] [mc "Linked projects"] $pjList $pjLinked] if {$pjLinked != -1} { - if {[::op::linkPjs $dbs $opData(id) $pjLinked] == -1} { + if {[::op::linkPjs $dbs $opData(uid) $pjLinked] == -1} { ::yacco::dbError } } @@ -1026,7 +1035,7 @@ file delete $out } -# hadling for event 'press button Contract' +# hadling for event 'press button Invoice' # proc ::yacco::onPressInvoice {db a2ps} { array set data [::yacco::get_fields 0] @@ -1035,87 +1044,7 @@ return } - set ::tk::db $db - set ::tk::a2ps $a2ps - array set ::tk::data [array get data] - - set ::yacco::pending [::op::getPendingInvoice $db $data(codfis)] - if {$::yacco::pending == -1} { - ::yacco::dbError - return - } - - if {[llength $::yacco::pending] == 0} { - if {[yatk_dlg::quest [mc "There's no pending invoice for this operator. \ - Do you want to procede with a generic invoice printing?"]] == 1} { - return - } - ::yacco::invoiceForm .invform $a2ps $db $data(codfis) - return - } else { - # choose what to pay - - set w .pays - set title [mc "Choose a payments to evade"] - - catch {destroy $w} - set focus [focus] - set grab [grab current .] - - # create a new toplevel in a "dialog mode" - - toplevel $w -bd 1 -relief raised -class TkSDialog - wm title $w $title - wm iconname $w $title - wm protocol $w WM_DELETE_WINDOW {#} - wm transient $w [winfo toplevel [winfo parent $w]] - - frame $w.frLst - scrollbar $w.frLst.sc -orient vertical -command {.pays.frLst.lstPay yview} \ - -borderwidth 0 - listbox $w.frLst.lstPay -width 0 -bg white -listvariable ::yacco::pending \ - -selectmode multiple -yscrollcommand {.pays.frLst.sc set} -width 60 - - grid $w.frLst.lstPay $w.frLst.sc -sticky news - - frame $w.bts - button $w.bts.ok -text [mc "Ok"] -image $::yatk_icons::ok -compound left \ - -command { - ::yacco::invoiceForm .pays.invform $::tk::a2ps $::tk::db $::tk::data(codfis) - # by now we don't use any infos from the payment choosed [.pays.frLst.lstPay curselection] - set ::yacco::iButton 1 - } - bind $w.bts.ok <Return> {%W invoke} - button $w.bts.clear -text [mc "Clear selection"] -image $::yatk_icons::clear -compound left \ - -command {.pays.frLst.lstPay selection clear 0 end} - button $w.bts.cancel -text [mc "Cancel"] -image $::yatk_icons::cancel -compound left \ - -command {set ::yacco::iButton 0} - foreach b [winfo child $w.bts] { - bind $b <Return> {%W invoke} - } - - grid $w.bts.cancel $w.bts.clear $w.bts.ok -padx [list 6 0] -sticky se - - grid $w.frLst -padx 12 -pady 12 -sticky news - grid $w.bts -padx 12 -pady 12 -sticky se - - wm withdraw $w - update idletasks - wm deiconify $w - focus -force $w - grab $w - tkwait variable ::yacco::iButton - bind $w <Destroy> {} - grab release $w - destroy $w - focus -force $focus - if {$grab != ""} {grab $grab} - update idletasks - } - - unset ::tk::db - unset ::tk::a2ps - unset ::tk::data + ::yacco::invoiceForm .invform $a2ps $db $data(codfis) } # trigged when the user press button Modify @@ -1125,9 +1054,9 @@ # trigged when the user press button Save # -# @param db_sample db sample hwn -proc ::yacco::onPressSave {db_int} { - array set ret [yacco::get_fields 0] +# @param db db sample hwn +proc ::yacco::onPressSave {db} { + array set ret [::yacco::get_fields 0] if { [array size ret] == 0 } { return } @@ -1144,7 +1073,7 @@ ::yalog::debug "$key = $value" } - if {[::op::saveOpData $db_int $ret(name) $ret(surname) $ret(addr) $ret(city) $ret(cap) $ret(tel1) \ + if {[::op::saveOpData $db $ret(name) $ret(surname) $ret(addr) $ret(city) $ret(cap) $ret(tel1) \ $ret(tel2) $ret(cell) $ret(email) $ret(bplace) $ret(bdate) $ret(active) $ret(note) $ret(points) \ $ret(alt_addr) $ret(alt_city) $ret(alt_cap) $ret(sex) $ret(type) $ret(codfis) $ret(salary) \ $ret(bank) $ret(bank_addr) $ret(bank_city) $ret(bank_abi) $ret(bank_cab) $ret(bank_cc) \ @@ -1196,15 +1125,13 @@ } -proc ::yacco::confDb {dbs dbi} { - global db_int db_sample +proc ::yacco::confDb {newdb} { + global db - ::yadb::disconnect $db_int - ::yadb::disconnect $db_sample + ::yadb::disconnect $db - set db_sample $dbs - set db_int $dbi - set ::yacco::db_int $dbi + set db $newdb + set ::yacco::db $newdb } proc ::yacco::configOpst {} { @@ -1237,7 +1164,7 @@ return } - ::yacco::addOpTy "update" + ::yacco::addOpTy "update" $pos } button $w.cmd.del -image $::yatk_icons::trash -text [mc "Delete"] -compound left \ -command { @@ -1255,7 +1182,7 @@ } } - if {[::op::delIntType $::yacco::db_int $idPos] == -1} { + if {[::op::delIntType $::yacco::db $idPos] == -1} { ::yacco::dbError return } @@ -1274,11 +1201,16 @@ grid x $w.cancel -sticky se -padx 12 -pady 12 } -proc ::yacco::addOpTy {{mode "add"}} { +proc ::yacco::addOpTy {{mode "add"} {pos ""}} { set w .confOpT.add if {$mode == "add"} { set title [mc "Add a new operator type"] } else { + if {$pos eq ""} { + ::yatk_dlg::error [mc "No selection has been passed! A bug occurs, please contact developers."] + return + } + set ::yacco::pos $pos set title [mc "Edit operator type"] } @@ -1301,11 +1233,11 @@ if {$mode == "add"} { $w.bts.add configure -text [mc "Add"] $w.bts.add configure -command { - if {[::op::addIntType $::yacco::db_int [.confOpT.add.fr.type get]] == -1} { + if {[::op::addIntType $::yacco::db [.confOpT.add.fr.type get]] == -1} { ::yacco::dbError return } - array set ::yacco::intTypes [::op::getIntTypes $::yacco::db_int] + array set ::yacco::intTypes [::op::getIntTypes $::yacco::db] set ::yacco::availableOpTypes [list] foreach id [array names ::yacco::intTypes] { lappend ::yacco::availableOpTypes $::yacco::intTypes($id) @@ -1316,8 +1248,7 @@ } else { $w.bts.add configure -text [mc "Update"] $w.bts.add configure -command { - set pos [.confOpT.op.lstOp curselection] - set type [lindex $::yacco::availableOpTypes $pos] + set type [lindex $::yacco::availableOpTypes $::yacco::pos] foreach id [array names ::yacco::intTypes] { if {$::yacco::intTypes($id) == $type} { set idPos $id @@ -1327,12 +1258,14 @@ set type [.confOpT.add.fr.type get] - if {[::op::updateIntType $::yacco::db_int $idPos $type] == -1} { + if {[::op::updateIntType $::yacco::db $idPos $type] == -1} { ::yacco::dbError return } set ::yacco::intTypes($idPos) $type - set ::yacco::availableOpTypes [lreplace $::yacco::availableOpTypes $pos $pos $type] + set ::yacco::availableOpTypes [lreplace $::yacco::availableOpTypes $::yacco::pos $::yacco::pos $type] + unset ::yacco::pos + .confOpT.add.bts.cancel invoke } } @@ -1356,16 +1289,16 @@ # trigged when the user press Cod.Fis or when tab # on it. # -# @param db_int db int hwn +# @param db db int hwn # @param not_used this is not used, but the tk focus event pass # two aegs, so this is here only for compatibility -proc ::yacco::onPressCodFis { db_int {not_used 0}} { +proc ::yacco::onPressCodFis { db {not_used 0}} { array set tmp [yacco::get_fields 1] if { [array size tmp] == 0 } { return } - set cf [yamisc::calc_cod_fisc $db_int $tmp(surname) $tmp(name) $tmp(bdate) $tmp(bplace) $tmp(sex)] + set cf [yamisc::calc_cod_fisc $db $tmp(surname) $tmp(name) $tmp(bdate) $tmp(bplace) $tmp(sex)] if { $cf== -1 } { set msg "Some entry caused an error on code calculation" switch -exact -- $::yamisc::err $::yamisc::ERR_NOCOM {set msg [mc "Operator's birth place caused \ @@ -1440,8 +1373,8 @@ ################################################################################ # Misc procs -proc ::yacco::fillInData {db_int codFisc} { - array set opData [::op::getOp $db_int $codFisc] +proc ::yacco::fillInData {db codFisc} { + array set opData [::op::getOp $db $codFisc] if {[array size opData] == 0} { yatk_dlg::error [mc "No data found for this operator."] return -1 @@ -1451,11 +1384,11 @@ # surname - .info.notebook.nbframe.pg_date.if.surname insert 0 $opData(cognome) + .info.notebook.nbframe.pg_date.if.surname insert 0 $opData(surname) # name - .info.notebook.nbframe.pg_date.if.name insert 0 $opData(nome) + .info.notebook.nbframe.pg_date.if.name insert 0 $opData(name) # sex @@ -1472,7 +1405,7 @@ # is the operator active? - if {$opData(inattivo) == "t"} { + if {$opData(active) == "t"} { set ::yacco::::CkActive 1 .info.notebook.nbframe.pg_note.disable invoke } else { @@ -1482,11 +1415,11 @@ # addr - .info.notebook.nbframe.pg_addr.adf.addr insert 0 $opData(indirizzo) + .info.notebook.nbframe.pg_addr.adf.addr insert 0 $opData(address) # city - .info.notebook.nbframe.pg_addr.adf.city insert 0 $opData(citta) + .info.notebook.nbframe.pg_addr.adf.city insert 0 $opData(city) # cap @@ -1494,24 +1427,24 @@ # tel1 - .info.notebook.nbframe.pg_date.if.tel1 insert 0 $opData(telefono1) + .info.notebook.nbframe.pg_date.if.tel1 insert 0 $opData(phone1) # tel2 - .info.notebook.nbframe.pg_date.if.tel2 insert 0 $opData(telefono2) + .info.notebook.nbframe.pg_date.if.tel2 insert 0 $opData(phone2) # cell - .info.notebook.nbframe.pg_date.if.cell insert 0 $opData(cellulare) + .info.notebook.nbframe.pg_date.if.cell insert 0 $opData(mobile) # bplace - .info.notebook.nbframe.pg_date.if.bplace insert 0 $opData(nato_a) + .info.notebook.nbframe.pg_date.if.bplace insert 0 $opData(bplace) # bdate .info.notebook.nbframe.pg_date.if.bdate delete 0 end - .info.notebook.nbframe.pg_date.if.bdate insert 0 [clock format [clock scan "$opData(nato_il)"] -format "%d/%m/%Y"] + .info.notebook.nbframe.pg_date.if.bdate insert 0 [clock format [clock scan "$opData(bdate)"] -format "%d/%m/%Y"] # codfis @@ -1529,15 +1462,15 @@ # alt_addr - .info.notebook.nbframe.pg_addr.adf.alt_addr insert 0 $opData(indres) + .info.notebook.nbframe.pg_addr.adf.alt_addr insert 0 $opData(res_address) # alt_city - .info.notebook.nbframe.pg_addr.adf.alt_city insert 0 $opData(cittares) + .info.notebook.nbframe.pg_addr.adf.alt_city insert 0 $opData(res_city) # alt_cap - .info.notebook.nbframe.pg_addr.adf.alt_cap insert 0 $opData(capres) + .info.notebook.nbframe.pg_addr.adf.alt_cap insert 0 $opData(res_cap) # note @@ -1545,32 +1478,32 @@ # points - .info.notebook.nbframe.pg_note.points insert 0 $opData(punteggio) + .info.notebook.nbframe.pg_note.points insert 0 $opData(score) # type - .info.notebook.nbframe.pg_note.type insert entry 0 $::yacco::intTypes($opData(tipo)) + .info.notebook.nbframe.pg_note.type insert entry 0 $::yacco::intTypes($opData(int_type)) # salary - .info.notebook.nbframe.pg_bank.salary insert 0 $opData(pagah) + .info.notebook.nbframe.pg_bank.salary insert 0 $opData(h_salary) - array set opBank [::op::getOpBank $db_int $codFisc] + array set opBank [::op::getOpBank $db $codFisc] if {[array size opBank] > 0} { #bank - .info.notebook.nbframe.pg_bank.bank insert 0 $opBank(banca) + .info.notebook.nbframe.pg_bank.bank insert 0 $opBank(bank) # bank_addr - .info.notebook.nbframe.pg_bank.addr insert 0 $opBank(indirizzo) + .info.notebook.nbframe.pg_bank.addr insert 0 $opBank(address) # bank_city - .info.notebook.nbframe.pg_bank.city insert 0 $opBank(citta) + .info.notebook.nbframe.pg_bank.city insert 0 $opBank(city) # bank_abi @@ -1582,38 +1515,38 @@ # bank_cc - .info.notebook.nbframe.pg_bank.cc insert 0 $opBank(conto_corrente) + .info.notebook.nbframe.pg_bank.cc insert 0 $opBank(checking_account) # bank_owner - .info.notebook.nbframe.pg_bank.owner insert 0 $opBank(intestatario) + .info.notebook.nbframe.pg_bank.owner insert 0 $opBank(owner) } - array set opDisp [::op::getOpDisp $db_int $codFisc] + array set opDisp [::op::getOpDisp $db $codFisc] if {[array size opDisp] > 0} { - if {$opDisp(disp_mat) == "t"} { + if {$opDisp(morning) == "t"} { set ::yacco::CkMorning 1 } else { set ::yacco::CkMorning 0 } - if {$opDisp(disp_pom) == "t"} { + if {$opDisp(afternoon) == "t"} { set ::yacco::CkAfternoon 1 } else { set ::yacco::CkAfternoon 0 } - if {$opDisp(disp_sera) == "t"} { + if {$opDisp(evening) == "t"} { set ::yacco::CkEvening 1 } else { set ::yacco::CkEvening 0 } # aviablefrom - .info.notebook.nbframe.pg_note.aviablefrom show [clock scan $opDisp(disp_dal)] + .info.notebook.nbframe.pg_note.aviablefrom show [clock scan $opDisp(available_from)] } return 0 @@ -1920,7 +1853,7 @@ } button $w.bts.print -text [mc "Print"] -image $::yatk_icons::fax -compound left \ -command { - array set data [yacco::get_fields] + array set data [::yacco::get_fields] if {[array size data] == 0} { ::yacco::dbError return @@ -2053,6 +1986,16 @@ grid $w.calcFrm $w.descFrm -sticky ns -padx 12 -pady 12 grid $w.bts - -sticky se -padx 6 -pady 12 + array set data [::yacco::get_fields] + if {[array size data] == 0} { + ::yacco::dbError + destroy $::yacco::wPath + return + } + + $w.calcFrm.ph delete 0 end + $w.calcFrm.ph insert 0 $data(salary) + wm withdraw $w update idletasks wm deiconify $w @@ -2072,14 +2015,14 @@ unset ::yacco::foButton } -proc ::yacco::findCombo {db_int fndList} { +proc ::yacco::findCombo {db fndList} { set fndField [lindex $fndList 0] set fndValue [lindex $fndList 1] if {$fndValue == ""} { # if no value... retrive all possible one - if {$fndField == "cognome"} { + if {$fndField == "surname"} { set obj .fnd.fr.sur @@ -2087,7 +2030,12 @@ $obj delete entry 0 end set idx 0 - foreach c [::op::getInfos $db_int $fndField] { + set surnames [::op::getInfos $db $fndField] + if {$surnames == -1} { + ::yalog::debug "no surnames found." + return + } + foreach c $surnames { $obj insert list $idx $c incr idx } @@ -2096,10 +2044,10 @@ set objs [list] - if {$fndField == "cognome"} { - lappend objs [list "nome" .fnd.fr.nam] [list "cod_fiscale" .fnd.fr.cod] + if {$fndField == "surname"} { + lappend objs [list "name" .fnd.fr.nam] [list "cod_fiscale" .fnd.fr.cod] } - if {$fndField == "nome"} { + if {$fndField == "name"} { lappend objs [list "cod_fiscale" .fnd.fr.cod] } @@ -2115,7 +2063,7 @@ if {$surn != "" && $name == ""} { set name "%" } - + foreach o $objs { set field [lindex $o 0] set obj [lindex $o 1] @@ -2123,12 +2071,11 @@ $obj delete list 0 end $obj delete entry 0 end set idx 0 - foreach c [::op::getFilteredInfos $db_int $field "cognome ilike '$surn' and nome ilike '$name'"] { + foreach c [::op::getFilteredInfos $db $field "surname ilike '$surn' and name ilike '$name'"] { $obj insert list $idx $c incr idx } } - } # clear all fields in the window @@ -2175,7 +2122,7 @@ $wdj insert list 0 [mc "Male"] $wdj insert list 1 [mc "Female"] - array set ::yacco::intTypes [::op::getIntTypes $::yacco::db_int] + array set ::yacco::intTypes [::op::getIntTypes $::yacco::db] if {[array size ::yacco::intTypes] == 0} { ::yatk_dlg::error [mc "No interviewer's type available. Go define them!"] return @@ -2326,65 +2273,45 @@ } ## -# check maybe db_sample is unusefull, we only use conenction to operators +# check maybe db is unusefull, we only use conenction to operators # db (think about integrate sample and int on the same db on 2 different schema) ## # Init db packages ::yalog::message "Connecting to db..." -set db_int [::yadb::connect $::yacco::config(DB_INT) $::yacco::config(HOST_INT) $::yacco::config(USER_INT) \ - $::yacco::config(PORT_INT)] -set db_sample [::yadb::connect $::yacco::config(DB_SAMPLE) $::yacco::config(HOST_SAMPLE) \ - $::yacco::config(USER_SAMPLE) $::yacco::config(PORT_SAMPLE)] -if {($db_int==-1) || ($db_sample==-1)} { +set db [::yadb::connect $::yacco::config(DB) $::yacco::config(HOST) \ + $::yacco::config(USER) $::yacco::config(PORT)] +if {$db == -1} { yatk_dlg::error [mc "Cannot connect to database(s) please check your conf"] exit } -set ::yacco::db_int $db_int +set ::yacco::db $db ## # Setting up connection loss handler -set loss_sample { - ::yalog::debug "Connection loss occurs on $::yacco::config(DB_SAMPLE)" - ::yadb::disconnect $db_sample - set db_sample [::yadb::connect $::yacco::config(DB_SAMPLE) $::yacco::config(HOST_SAMPLE) \ - $::yacco::config(USER_SAMPLE) $::yacco::config(PORT_SAMPLE)] - if {$db_sample == -1} { - ::yalog::debug "After a connection loss on $::yacco::config(DB_SAMPLE) we're not able to riconnect. exit now!" +set loss_db { + ::yalog::debug "Connection loss occurs on $::yacco::config(DB)" + ::yadb::disconnect $db + set db [::yadb::connect $::yacco::config(DB) $::yacco::config(HOST) \ + $::yacco::config(USER) $::yacco::config(PORT)] + if {$db == -1} { + ::yalog::debug "After a connection loss on $::yacco::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!"] + It's safer to exit now!"] exit } - ::yadb::onConnectionLoss $db_sample $loss_sample - ::yalog::debug "After a connection loss on $::yacco::config(DB_SAMPLE) we're able to riconnect!" + ::yadb::onConnectionLoss $db $loss_db + ::yalog::debug "After a connection loss on $::yacco::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 ::yacco::db $db } -set loss_int { - ::yalog::debug "Connection loss occurs on $::yacco::config(DB_INT)" - ::yadb::disconnect $db_int - set db_int [::yadb::connect $::yacco::config(DB_INT) $::yacco::config(HOST_INT) $::yacco::config(USER_INT) \ - $::yacco::config(PORT_INT)] - if {$db_int == -1} { - ::yalog::debug "After a connection loss on $::yacco::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 $::yacco::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_db -::yadb::onConnectionLoss $db_sample $loss_sample -::yadb::onConnectionLoss $db_int $loss_int - yacco::update_status start yacco::update_status normal yalog::message "Started." This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |