// ppljobregentry_1 (fpl)
// ++++++++++++
string uname
string utag
ins:active = FALSE

upd:active = FALSE

del:active = FALSE

jrslno:visible = FALSE

jramdno:visible = FALSE

jramddt:visible = FALSE

if (mychannel3:open = FALSE) then
end if

select user_name()

into uname

from dual


if uname = "cospr" then
    utag = "C"

else
    utag = "P"

end if

// /*      if ((select count(*) from sysobjects where name = 'tmpjobreg' */
// /*                  and type = 'U' and uid in(select uid from sysusers */
// /*                  where  name=user_name())) > 0) */
// /*          drop table ..tmpjobreg */

if (mychannel3:open = TRUE) then
end if

return

// ------------
 
 
// ppljobregexit_1 (fpl)
// ++++++++++++
if (mychannel3:open = FALSE) then
end if

// /*     drop table ..tmpjobcomp */
// /*     drop table ..tmpjobpln */
// /*     drop table ..tmpjobdesp */

// /*      if ((select count(*) from sysobjects where name = 'tmpjobreg' */
// /*                  and type = 'U' and uid in(select uid from sysusers */
// /*                  where name=user_name() ))  > 0) */
// /*          drop table tmpjobreg */

return

// ------------
 
 
// ppljobregfrmext_1 (fpl)
// ++++++++++++
CHANNEL mychannel
if (mychannel:open = FALSE) then
end if

// /*      drop table ..tmpjobreg */
// /*      drop table ..tmpjobcomp */
// /*      drop table ..tmpjobpln */
// /*         drop table ..tmpjobdesp */
// /*      drop table ..tmpjobchng */
// /*      drop table ..tmpjobscrpdet */

return

// ------------
 
 
// ppljobregins_1 (fpl)
// ++++++++++++
string mssg
long sflag
string utag
if (mychannel:open = FALSE) then
end if

SetNull(mychannel:errors)
begin transaction

if (IsNull(mychannel:errors)) then
    insert jobreg
    (
        jrjobno
        , jrflag
        , jrslno
        , jrclientcd
        , jrqtnno
        , jrqtndt
        , jrordno
        , jrconsdet
        , jrordplby
        , jrorddt
        , jrcdsrecvdt
        , jrdestin
        , jrdesmode
        , jrotsrecvdt
        , jrbmrecvdt
        , jrpumpcat
        , jrqty
        , jrpmpval
        , jrmndtval
        , jrinsp
        , jrdrvval
        , jrcondeldt
        , jrpumpmodel
        , jrindreledt
        , user_id
        , systime
        )
    values (
        jrjobno
        , "S"
        , jrslno
        , jrclientcd
        , jrqtnno
        , jrqtndt
        , jrordno
        , jrconsdet
        , jrordplby
        , jrorddt
        , jrcdsrecvdt
        , jrdestin
        , jrdesmode
        , jrotsrecvdt
        , jrbmrecvdt
        , sqlexpr(jrpumpcat)
        , sqlexpr(jrqty)
        , jrpmpval
        , jrmndtval
        , jrinsp
        , jrdrvval
        , jrcondeldt
        , jrpumpmodel
        , sqlexpr(jrindreledt)
        , user_name()
        , getdate()
        )


end if

if utag = "P" then
    if (IsNull(mychannel:errors)) then
        insert into jobplndesp
        select *
        from tmpjobpln


    end if

    if (IsNull(mychannel:errors)) then
        insert into jobcomp
        select *
        from tmpjobcomp


    end if

    if (IsNull(mychannel:errors)) then
        insert into jobactdesp
        select *
        from tmpjobdesp


    end if


end if

if (IsNull(mychannel:errors)) then
    insert into jobchng
    select *
    from tmpjobchng


end if

if sflag = 1 then
    if (IsNull(mychannel:errors)) then
        insert into jobscrpdet
        select *
        from tmpjobscrpdet


    end if


end if

if (IsNull(mychannel:errors)) then
    commit transaction

    mssg = "Record Inserted Successfully"

    MessageBox ("Please_Note", mssg)
    call ppljobregcls_1 ()

else
    rollback transaction

    mssg = "INSERT UNSUCCESSFULL"

    MessageBox ("Please_Note", mssg)

end if

return

// ------------
 
 
// ppljobregupd_1 (fpl)
// ++++++++++++
string mssg
long sflag
string utag
string utabname
if (mychannel:open = FALSE) then
end if

select ltrim(rtrim(user_id))

into utabname

from jobreg
where jrjobno = jrjobno


if (utabname = "plan1"  &
AND utag = "C") then
    mssg = "Allready Updated from Panihati"

    MessageBox ("Please_Note", mssg)
    mssg = "You are not Authorised ..."

    MessageBox ("Please_Note", mssg)
    return

end if

begin transaction
update jobreg
set jrslno = sqlexpr(jrslno)
    , jrclientcd = sqlexpr(jrclientcd)
    , jrqtnno = sqlexpr(jrqtnno)
    , jrqtndt = sqlexpr(jrqtndt)
    , jrordno = sqlexpr(jrordno)
    , jrorddt = sqlexpr(jrorddt)
    , jrcdsrecvdt = sqlexpr(jrcdsrecvdt)
    , jrbmrecvdt = sqlexpr(jrbmrecvdt)
    , jrconsdet = jrconsdet
    , jrordplby = jrordplby
    , jrdestin = sqlexpr(jrdestin)
    , jrdesmode = sqlexpr(jrdesmode)
    , jrotsrecvdt = sqlexpr(jrotsrecvdt)
    , jrpumpcat = sqlexpr(jrpumpcat)
    , jrpumpmodel = sqlexpr(jrpumpmodel)
    , jrqty = sqlexpr(jrqty)
    , jrpmpval = sqlexpr(jrpmpval)
    , jrmndtval = sqlexpr(jrmndtval)
    , jrinsp = sqlexpr(jrinsp)
    , jrdrvval = sqlexpr(jrdrvval)
    , jrcondeldt = sqlexpr(jrcondeldt)
    , jrindreledt = sqlexpr(jrindreledt)
    , user_id = user_name()
    , systime = getdate()
where jobreg.jrjobno = sqlexpr(jrjobno)


if (NOT IsNull(mychannel:errors)) then
    mssg = "Record Could Not Be Updated"

    callform msgbox_1 ()
    call ppljobregcls
    rollback transaction

    return

end if

if utag = "P" then
    delete jobcomp
    where jcjobno = jrjobno

    delete from jobplndesp
    where jpjobno = jrjobno

    delete from jobactdesp
    where jdjobno = jrjobno



end if

delete from jobchng
where chjobno = jrjobno


if sflag = 1 then
    delete from jobscrpdet
    where jscjobno = jrjobno

    insert into jobscrpdet
    select *
    from tmpjobscrpdet



end if

if utag = "P" then
    insert into jobcomp
    select *
    from tmpjobcomp

    insert into jobplndesp
    select *
    from tmpjobpln

    insert into jobactdesp
    select *
    from tmpjobdesp



end if

insert into jobchng
select *
from tmpjobchng


if (IsNull(mychannel:errors)) then
    mssg = "Record Successfully Updated"

    callform msgbox_1 ()
    commit transaction

    call ppljobregcls_1 ()
    jrjobno.setFocus()

else
    rollback transaction

    mssg = "Updation Failure! Retry ..."

    callform msgbox_1 ()

end if

return

// ------------
 
 
// ppljrdel_1 (fpl)
// ++++++++++++
string mssg
string rem
string cnf
int amndno
callform strconf_1
if cnf = "N" then
    return
end if

if (mychannel:open = FALSE) then
end if

SetNull(mychannel:errors)
begin transaction

delete jobreg
where jobreg.jrjobno = sqlexpr(jrjobno)


if (IsNull(mychannel:errors)) then
    delete jobcomp
    where jcjobno = jrjobno


end if

if (IsNull(mychannel:errors)) then
    delete from jobplndesp
    where jpjobno = jrjobno


end if

if (IsNull(mychannel:errors)) then
    delete from jobactdesp
    where jdjobno = jrjobno


end if

if (NOT IsNull(mychannel:errors)) then
    mssg = "Record Could Not Be Deleted"

    rollback transaction

    callform msgbox_1 ()
    return

else
    mssg = "Record Deleted Successfully"

    commit transaction

    MessageBox ("Please_Note", mssg)
    call ppljobregcls_1

end if

return

// ------------
 
 
// ppljobregcls_1 (fpl)
// ++++++++++++
foreach f in $curform
    if (f:datatype = 50) then
        f = f:default

    else
        SetNull(f)
    end if

    f:modified = FALSE


next

save form
foreach j in $curform
    j.setFocus()
    break

next

jrqty:visible = TRUE

jrdrvval:visible = TRUE

jrmndtval:visible = TRUE

jrpmpval:visible = TRUE

jrpmpval:visible = TRUE

lstsprsl:visible = FALSE

if (mychannel3:open = FALSE) then
end if

// /*      if ((select count(*) from sysobjects where name = 'tmpjobreg' */
// /*                  and type = 'U') > 0) */
// /*          drop table tmpjobreg */

if (mychannel3:open = TRUE) then
end if

call ppljobregentry_1 ()
jrjobno.setFocus()
return

// ------------
 
 
// ppljramnd_1 (fpl)
// ++++++++++++
string mssg
string rem
int amndno
long yflag
if (mychannel:open = FALSE) then
end if

SetNull(mychannel:errors)
// /* ACTIVE */
// /*     if ((select count(*) from tmpjobreg */
// /*         where jrjobno      = jrjobno      and */
// /*             jrslno         = jrslno         and */
// /*             jrclientcd     = jrclientcd   and */
// /*             jrqtnno        = jrqtnno      and */
// /*             jrqtndt        = jrqtndt      and */
// /*             jrordno        = jrordno      and */
// /*             jrorddt        = jrorddt      and */
// /*             jrcdsrecvdt    = jrcdsrecvdt  and */
// /*             jrdestin       = jrdestin     and */
// /*             jrdesmode      = jrdesmode    and */
// /*             jrotsrecvdt    = jrotsrecvdt  and */
// /*             jrbmrecvdt     = jrbmrecvdt   and */
// /*             jrpumpcat      = jrpumpcat      and */
// /*             jrindreledt    = jrindreledt  and */
// /*             jrpumpmodel    = jrpumpmodel  and */
// /*             jrqty          = jrqty          and */
// /*             jrpmpval       = jrpmpval       and */
// /*             jrmndtval      = jrmndtval      and */
// /*             jrinsp         = jrinsp       and */
// /*             jrdrvval       = jrdrvval       and */
// /*             jrcondeldt     = jrcondeldt   and */
// /*             jrconsdet      = jrconsdet    and */
// /*             jrordplby      = jrordplby    and */
// /*             jramdno        = jramdno        and */
// /*             jramddt        = jramddt) = 1) */
// /*             select yflag = 1 */
// /*         else */
// /*             select yflag = 0 */

if yflag = 1 then
    mssg = "NO CHANGE DONE ..."

    MessageBox ("Please_Note", mssg)
    return

end if

callform ppljobrem_1
if (mychannel:open = FALSE) then
end if

begin transaction

if (IsNull(mychannel:errors)) then
    select amndno = goamndno
    , gojobno

    from garbageord
    where gojobno = jrjobno
    having goamndno = max(goamndno)


end if

if mychannel:count = 0 then
    amndno = 1

else
    amndno = amndno + 1

end if

// /* Update Job Register with new rec */
if (IsNull(mychannel:errors)) then
    update jobreg
    set jrclientcd = sqlexpr(jrclientcd)
        , jrqtnno = sqlexpr(jrqtnno)
        , jrqtndt = sqlexpr(jrqtndt)
        , jramdno = amndno
        , jramddt = getdate()
        , jrordno = sqlexpr(jrordno)
        , jrorddt = sqlexpr(jrorddt)
        , jrcdsrecvdt = sqlexpr(jrcdsrecvdt)
        , jrconsdet = jrconsdet
        , jrdestin = sqlexpr(jrdestin)
        , jrdesmode = sqlexpr(jrdesmode)
        , jrotsrecvdt = sqlexpr(jrotsrecvdt)
        , jrpumpcat = sqlexpr(jrpumpcat)
        , jrqty = sqlexpr(jrqty)
        , jrpmpval = sqlexpr(jrpmpval)
        , jrmndtval = sqlexpr(jrmndtval)
        , jrinsp = sqlexpr(jrinsp)
        , jrdrvval = sqlexpr(jrdrvval)
        , jrcondeldt = sqlexpr(jrcondeldt)
        , user_id = user_name()
        , systime = getdate()
    where jobreg.jrjobno = sqlexpr(jrjobno)


end if

// /* Deleting Current Job Comp Det */
if (IsNull(mychannel:errors)) then
    delete jobcomp
    where jcjobno = jrjobno


end if

if (IsNull(mychannel:errors)) then
    delete from jobplndesp
    where jpjobno = jrjobno


end if

if (IsNull(mychannel:errors)) then
    delete from jobactdesp
    where jdjobno = jrjobno


end if

if (IsNull(mychannel:errors)) then
    insert into jobcomp
    select *
    from tmpjobcomp


end if

if (IsNull(mychannel:errors)) then
    insert into jobplndesp
    select *
    from tmpjobpln


end if

if (IsNull(mychannel:errors)) then
    insert into jobactdesp
    select *
    from tmpjobdesp


end if

if (IsNull(mychannel:errors)) then
    insert garbageord
    (
        goamndno
        , gojobno
        )
    values (
        amndno
        , jrjobno
        )


end if

if (IsNull(mychannel:errors)) then
    update garbageord
    set goflag = tmpjobreg.jrflag
        , goslno = tmpjobreg.jrslno
        , goclientcd = tmpjobreg.jrclientcd
        , goconsdet = tmpjobreg.jrconsdet
        , goordno = tmpjobreg.jrordno
        , goorddt = tmpjobreg.jrorddt
        , gocdsrecvdt = tmpjobreg.jrcdsrecvdt
        , godestin = tmpjobreg.jrdestin
        , godesmode = tmpjobreg.jrdesmode
        , gootsrecvdt = tmpjobreg.jrotsrecvdt
        , gobmrecvdt = tmpjobreg.jrbmrecvdt
        , gopumpcat = tmpjobreg.jrpumpcat
        , goindreledt = tmpjobreg.jrindreledt
        , gopumpmodel = tmpjobreg.jrpumpmodel
        , goqty = tmpjobreg.jrqty
        , gopmpval = tmpjobreg.jrpmpval
        , gomndtval = tmpjobreg.jrmndtval
        , godrvval = tmpjobreg.jrdrvval
        , gocondeldt = tmpjobreg.jrcondeldt
        , goamnd = tmpjobreg.jramnd
        , gorem = rem
        , user_id = tmpjobreg.user_id
        , systime = tmpjobreg.systime

    from tmpjobreg
    where goamndno = amndno
    AND gojobno = jrjobno


end if

if (IsNull(mychannel:errors)) then
    mssg = "Record Successfully Amended"

    callform msgbox_1 ()
    commit transaction

    if (mychannel:open = TRUE) then
    end if

    call ppljobregcls_1 ()

else
    rollback transaction

    if (mychannel:open = TRUE) then
    end if

    mssg = "Amendment Failure! Retry ..."

    MessageBox ("Please_Note", mssg)

end if

return

// ------------
 
 
// ppljobregprn_1 (fpl)
// ++++++++++++
string mssg
string sqlquery
if IsNull(jobyear)  &
AND IsNull(fromdt) then
    return
end if

if mychannel:open = FALSE then
end if

// /*      if exists ( select * from sysobjects */
// /*                  where name = 'tmprepjobreg' and type = 'U') */
// /*          drop table tmprepjobreg */
// /*      if exists ( select * from sysobjects */
// /*                  where name = 'tmprepjobreg2' and type = 'U') */
// /*          drop table tmprepjobreg2 */

if NOT IsNull(fromdt) then
    select "JOB REGISTER FROM " + rtrim(convert(char(2), datepart(dd,fromdt))) + "/" + rtrim(convert(char(2), datepart(mm,fromdt))) + "/" + convert(char(4),
      datepart(yy,fromdt)) + " TO " + rtrim(convert(char(2), datepart(dd,todt))) + "/" + rtrim(convert(char(2), datepart(mm,todt))) + "/" + convert(char(4),
      datepart(yy,todt))

    into fjobreghead

    from dual


    SELECT jrjobno
    , jrslno
    , jramdno
    , jrclientcd
    , jrordno
    , jrcondeldt
    , jrconsdet
    , jrorddt
    , jrpumpmodel
    , jrpumpcat
    , jrcdsrecvdt
    , jrdestin
    , jrotsrecvdt
    , jrbmrecvdt
    , jrdesmode
    , jrindreledt
    , jrpmpval
    , jrtotdespval = convert(float,0)

    INTO tmprepjobreg

    FROM jobreg
    WHERE systime between fromdt and todt



else
    select "      JOB REGISTER FOR [" + upper(jobyear) + "] JOBS"

    into fjobreghead

    from dual


    SELECT jrjobno
    , jrslno
    , jramdno
    , jrclientcd
    , jrordno
    , jrcondeldt
    , jrconsdet
    , jrorddt
    , jrpumpmodel
    , jrpumpcat
    , jrcdsrecvdt
    , jrdestin
    , jrotsrecvdt
    , jrbmrecvdt
    , jrdesmode
    , jrindreledt
    , jrpmpval
    , jrtotdespval = convert(float,0)

    INTO tmprepjobreg

    FROM jobreg
    WHERE substring(jrjobno,2,2) = upper(jobyear)



end if

if IsNull(mychannel:errors) then
    select jcjobno
    , totdesp = sum(jcprtval)

    into tmprepjobreg2

    from jobcomp, tmprepjobreg
    where jobcomp.jcjobno = tmprepjobreg.jrjobno
    group by jcjobno



end if

if IsNull(mychannel:errors) then
    update tmprepjobreg
    set jrtotdespval = totdesp

    from tmprepjobreg2 a, tmprepjobreg b
    where a.jcjobno = b.jrjobno



end if

if NOT IsNull(mychannel:errors) then
    mssg = "ERROR IN CREATING REPORT..."

    MessageBox ("Please_Note", mssg)
// /* This ensures that the report is not printed */
    SetNull(jobyear)
    SetNull(fromdt)

end if

return

// ------------
 
 
// ppljobregscr_1 (fpl)
// ++++++++++++
long from_ln
long to_ln
if IsNull(jobyear)  &
AND IsNull(fromdt) then
    return
end if

system "runrw wpilppc.plan1.ppljobreg -U $LOGNAME -P $PASSWORD -W 132 -H 72 -o report.jobreg -V jobreghead \"%\"", fjobreghead
if IsNull(frompg)  &
OR IsNull(topg) then
    system "ted -r report.jobreg"
    system "tput clear"
    system "echo PRESS [CTRL]W TO REFREASH SCREEN"
    system "rm report.jobreg"
    return

end if

if frompg > topg  &
OR frompg < 1 then
    print "Invalid page range "
    system "rm report.jobreg"
    return

end if

to_ln = topg * 72

from_ln = ((frompg - 1) * 72) + 1

system "head -\"%\" report.jobreg > rep.jobreg", to_ln
system "tail +\"%\" rep.jobreg > rep1.jobreg", from_ln
system "ted -r rep1.jobreg"
system "tput clear"
system "echo PRESS [CTRL]W TO REFREASH SCREEN"
system "rm report.jobreg"
system "rm rep.jobreg"
system "rm rep1.jobreg"
return

// ------------
 
 
// ppljobregprn_1 (fpl)
// ++++++++++++
string mssg
string sqlquery
if IsNull(jobyear)  &
AND IsNull(fromdt) then
    return
end if

if mychannel:open = FALSE then
end if

// /*      if exists ( select * from sysobjects */
// /*                  where name = 'tmprepjobreg' and type = 'U') */
// /*          drop table tmprepjobreg */
// /*      if exists ( select * from sysobjects */
// /*                  where name = 'tmprepjobreg2' and type = 'U') */
// /*          drop table tmprepjobreg2 */

if NOT IsNull(fromdt) then
    select "JOB REGISTER FROM " + rtrim(convert(char(2), datepart(dd,fromdt))) + "/" + rtrim(convert(char(2), datepart(mm,fromdt))) + "/" + convert(char(4),
      datepart(yy,fromdt)) + " TO " + rtrim(convert(char(2), datepart(dd,todt))) + "/" + rtrim(convert(char(2), datepart(mm,todt))) + "/" + convert(char(4),
      datepart(yy,todt))

    into fjobreghead

    from dual


    SELECT jrjobno
    , jrslno
    , jramdno
    , jrclientcd
    , jrordno
    , jrcondeldt
    , jrconsdet
    , jrorddt
    , jrpumpmodel
    , jrpumpcat
    , jrcdsrecvdt
    , jrdestin
    , jrotsrecvdt
    , jrbmrecvdt
    , jrdesmode
    , jrindreledt
    , jrpmpval
    , jrtotdespval = convert(float,0)

    INTO tmprepjobreg

    FROM jobreg
    WHERE systime between fromdt and todt



else
    select "      JOB REGISTER FOR [" + upper(jobyear) + "] JOBS"

    into fjobreghead

    from dual


    SELECT jrjobno
    , jrslno
    , jramdno
    , jrclientcd
    , jrordno
    , jrcondeldt
    , jrconsdet
    , jrorddt
    , jrpumpmodel
    , jrpumpcat
    , jrcdsrecvdt
    , jrdestin
    , jrotsrecvdt
    , jrbmrecvdt
    , jrdesmode
    , jrindreledt
    , jrpmpval
    , jrtotdespval = convert(float,0)

    INTO tmprepjobreg

    FROM jobreg
    WHERE substring(jrjobno,2,2) = upper(jobyear)



end if

if IsNull(mychannel:errors) then
    select jcjobno
    , totdesp = sum(jcprtval)

    into tmprepjobreg2

    from jobcomp, tmprepjobreg
    where jobcomp.jcjobno = tmprepjobreg.jrjobno
    group by jcjobno



end if

if IsNull(mychannel:errors) then
    update tmprepjobreg
    set jrtotdespval = totdesp

    from tmprepjobreg2 a, tmprepjobreg b
    where a.jcjobno = b.jrjobno



end if

if NOT IsNull(mychannel:errors) then
    mssg = "ERROR IN CREATING REPORT..."

    MessageBox ("Please_Note", mssg)
// /* This ensures that the report is not printed */
    SetNull(jobyear)
    SetNull(fromdt)

end if

return

// ------------
 
 
// ppljobregprint_1 (fpl)
// ++++++++++++
long from_ln
long to_ln
if IsNull(jobyear)  &
AND IsNull(fromdt) then
    return
end if

system "runrw wpilppc.plan1.ppljobreg -U $LOGNAME -P $PASSWORD -W 132 -H 72 -o report.jobreg -V jobreghead \"%\"", fjobreghead
if IsNull(frompg)  &
OR IsNull(topg) then
    system "lcpr2  report.jobreg"
    system "tput clear"
    system "echo PRESS [CTRL]W TO REFREASH SCREEN"
    system "rm report.jobreg"
    return

end if

if frompg > topg  &
OR frompg < 1 then
    print "Invalid page range "
    system "rm report.jobreg"
    return

end if

to_ln = topg * 72

from_ln = ((frompg - 1) * 72) + 1

system "head -\"%\" report.jobreg > rep.jobreg", to_ln
system "tail +\"%\" rep.jobreg > rep1.jobreg", from_ln
system "lcpr2  rep1.jobreg"
system "tput clear"
system "echo PRESS [CTRL]W TO REFREASH SCREEN"
system "rm report.jobreg"
system "rm rep.jobreg"
system "rm rep1.jobreg"
return

// ------------
 
 
// ppljrjobnoent_1 (fpl)
// ++++++++++++
if IsNull($curfield) then
    return
end if

save field $curfield
return

// ------------
 
 
// ppljobregjobnoext_1 (fpl)
// ++++++++++++
string mssg
// /* Job No */
string jobno
// /* Total number of pumps */
int qty
// /* Rate of each pump */
decimal pmprate
// /* Value of Pumps */
decimal pmpval
// /* Order Date     */
datetime gjrorddt
// /* B/M Recv. Dt.  */
datetime bmdt
// /* Drive Value */
decimal drvrate
// /* Total Value for SPARES job */
decimal sprval
// /* Mandatory Spares Value */
decimal mndtval
// /* P for planning, C for Contracts */
string utag
// /* 1 for Spares , else 0  */
long sflag
long pflag
long mflag
long jcflag
long jpflag
long jdflag
long slno
// /* First Pump Number */
string firstpump
// /* Last  Pump Number */
string lastpump
long merrflag
string regflg
// /* Cannot leave Job Number Blank */
if (IsNull($curfield)) then
    this.setFocus()
    return

end if

if (mychannel:open = FALSE) then
end if

select substring($curfield, 4, 1)

into regflg

from dual


if regflg = " "  &
OR regflg = "0"  &
OR regflg > "9" then
    this.setFocus()
    return

end if

// /* If no change - Don't process */
if ($curfield = $curfield:savedvalue) then
    return
end if

// /* Newly entered JobNo To Global Variable */
$curfield = upper($curfield)

jobno = $curfield

// /* Order Date */
SetNull(gjrorddt)
jcflag = 1

jpflag = 1

jdflag = 1

pflag = 0

mflag = 0

sflag = 0

// /* Spares Job */
if substring($curfield, 13, 1) = "S" then
    SetNull(jrqty)
    SetNull(qty)
    jrqty:visible = FALSE

    jrmndtval:visible = FALSE

    jrpmpval:visible = TRUE

    jrslno:visible = TRUE

    lstsprsl:visible = TRUE

// /* Enter Spares Serial No */ 
    jrslno.setFocus()
    sflag = 1

    mflag = 0

    pflag = 0


end if

if (utag = "C"  &
AND sflag = 0) then
    mssg = "U are not Authorised for PUMPS"

    MessageBox ("Please_Note", mssg)
    SetNull($curfield)
    this.setFocus()
    return

end if

if (mychannel:open = FALSE) then
end if

// /* FIND JOB DETAILS IN JOB REGISTER */
select *
from jobreg
where jrjobno = jrjobno


if mychannel:count > 0 then
// /* FIND QUOTATION No. AND DATE from bomh */
    select clntnam

    from client
    where clntcd = jrclientcd

    select bmhquotno
    , bmhquotdt

    into jrqtnno, jrqtndt

    from bomh
    where bmhjobno = $curfield


// /* FOR VERTICAL PUMP */
// /* HORIZONTAL PUMP */
// /* Break Up for Pump Model */
    if NOT IsNull(jrpumpmodel) then
        if substring(jrjobno,1,1) = "H" then
            pmodel1 = substring(jrpumpmodel,1,2)

            pmodel2 = substring(jrpumpmodel,3,2)

            pmodel3 = substring(jrpumpmodel,5,7)


        else
            pmodel1 = substring(jrpumpmodel,1,2)

            pmodel2 = substring(jrpumpmodel,4,2)

            pmodel3 = substring(jrpumpmodel,7,5)


        end if


    end if

    if IsNull(jramdno) then
        jramdno:visible = FALSE

        jramddt:visible = FALSE


    else
        jramdno:visible = TRUE

        jramddt:visible = TRUE


    end if

    qty = jrqty

    bmdt = jrbmrecvdt

    pmpval = jrpmpval

    pmprate = jrpmpval / jrqty

    drvrate = jrdrvval / jrqty

    if (NOT IsNull(jrqty)) then
        pflag = 1

    end if

// /* Mandatory Value */
    mndtval = jrmndtval

    if IsNull(mndtval) then
        mndtval = 0

    end if

// /* Total Value for the Job */
    if sflag = 1 then
        sprval = jrpmpval

    else
        pmpval = jrpmpval

    end if

// /*          if ((select count(*) from sysobjects */
// /*              where name = 'tmpjobreg' and type = 'U' and uid in( select */
// /*              uid from sysusers where name=user_name() ))  = 1) */
// /*              drop table ..tmpjobreg */

    select *
    into tmpjobreg

    from jobreg
    where jobreg.jrjobno = jrjobno


    ins:active = FALSE

    upd:active = TRUE

    if utag <> "C" then
        del:active = TRUE

    end if


else
    jramdno:visible = FALSE

    jramddt:visible = FALSE

    ins:active = TRUE

    upd:active = FALSE

    del:active = FALSE

// /* No check for Spares job */
    if sflag = 0 then
        select rtrim(ltrim(substring(jrjobno,4,4)))

        into firstpump

        from dual

        select rtrim(ltrim(substring(jrjobno,8,4)))

        into lastpump

        from dual


        merrflag = 0

        if IsNull(lastpump) then
            lastpump = firstpump

        end if

        if NOT IsNull(firstpump) then
// /*    ACTIVE        if (char_length(firstpump) < 4) */
// /*                         select merrflag = 1 */


        else
            merrflag = 1

        end if

        if merrflag = 0 then
            select (convert(int,lastpump) - convert(int,firstpump)) + 1

            into jrqty

            from dual



        end if

        if jrqty <= 0  &
        OR merrflag = 1  &
        OR NOT IsNull(mychannel:errors) then
            mssg = "Invalid Job No."

            if (mychannel:open = TRUE) then
            end if

            MessageBox ("Please_Note", mssg)
            SetNull($curfield)
            SetNull(jrqty)
            this.setFocus()
            return

        else
            select substring(jrjobno,1,3) + firstpump + lastpump + substring(jrjobno,12,2)

            into jrjobno

            from dual



        end if


    end if


end if

// /*      if exists(select * from sysobjects */
// /*                  where name = 'tmpjobcomp' and type = 'U' and uid in(select */
// /*                   uid from sysusers where name=user_name() )) */
// /*          drop table ..tmpjobcomp */
// /* */
// /*      if exists(select * from sysobjects */
// /*                  where name = 'tmpjobpln' and type = 'U' and uid in(select */
// /*                   uid from sysusers where name=user_name() )) */
// /*          drop table ..tmpjobpln */
// /* */
// /*      if  exists(select * from sysobjects */
// /*                  where name = 'tmpjobdesp' and type = 'U' and uid in(select */
// /*                   uid from sysusers where name=user_name() )) */
// /*          drop table ..tmpjobdesp */
// /* */
// /*      if  exists(select * from sysobjects */
// /*                  where name = 'tmpjobchng' and type = 'U' and uid in (select */
// /*                   uid from sysusers where name=user_name() )) */
// /*          drop table ..tmpjobchng */
// /* */
// /*      if  exists(select * from sysobjects */
// /*                  where name ='tmpjobscrpdet' and type='U' and uid in (select */
// /*                   uid from sysusers where name=user_name() )) */
// /*          drop table ..tmpjobscrpdet */

// /* Spares    */
if sflag = 1 then
// /*          if  exists(select * from sysobjects */
    print
      "// /*                  where name ='tmpjobscrpdet' and type ='U' and uid in (select                    uid from sysusers where name=user_name() )) */"
// /*              drop table ..tmpjobscrpdet */

    select *
    into tmpjobscrpdet

    from jobscrpdet
    where jscjobno = jrjobno



end if

if utag = "P" then
// /*  Job Despatch Schedule  */
    select *
    into tmpjobpln

    from jobplndesp
    where jpjobno = jrjobno
    order by jpyr, jpmth

// /*  Actual Completion Details */
    select *
    into tmpjobcomp

    from jobcomp
    where jcjobno = jrjobno

// /* Job Actual Despatch      */
    select *
    into tmpjobdesp

    from jobactdesp
    where jdjobno = jrjobno



end if

// /* Job Change Order Details */
select *
into tmpjobchng

from jobchng
where chjobno = jrjobno


if (mychannel:open = TRUE) then
end if

return

// ------------
 
 
// jobregclntcdentr_1 (fpl)
// ++++++++++++
if IsNull(jrjobno) then
    jrjobno.setFocus()
end if

return

// ------------
 
 
// ppljobregclcdexit_1 (fpl)
// ++++++++++++
string utag
string mssg
if (mychannel:open = FALSE) then
end if

if IsNull(jrjobno) then
    jrjobno.setFocus()
    return

end if

if (IsNull(jrclientcd)) then
    this.setFocus()
    return

end if

$curfield = upper($curfield)

select clntnam

from client
where clntcd = jrclientcd


if (mychannel:count = 0) then
    mssg = "Invalid Client Code ... "

    callform msgbox_1 ()
    this.setFocus()
    return

end if

if utag = "P" then
    jrordno.setFocus()
end if

return

// ------------
 
 
// ppljobregjrordnoext_1 (fpl)
// ++++++++++++
string utag
long sflag
$curfield = upper($curfield)

if $curform:backtab = TRUE then
    if utag = "P" then
        jrclientcd.setFocus()
    end if

end if

return

// ------------
 
 
// ppljrorddtext_1 (fpl)
// ++++++++++++
datetime gjrorddt
gjrorddt = $curfield

return

// ------------
 
 
// pplcdsent_1 (fpl)
// ++++++++++++
string utag
if utag = "C" then
    jrdestin.setFocus()
end if

return

// ------------
 
 
// ppljrcdsrecvdtext_1 (fpl)
// ++++++++++++
string mssg
if IsNull($curfield) then
    return
end if

if $curfield < jrorddt then
    mssg = "Error ! Smaller than Order Dt"

    MessageBox ("Please_Note", mssg)
    $curfield = $curfield:savedvalue

    this.setFocus()

end if

return

// ------------
 
 
// ppljobregjrdestinext_1 (fpl)
// ++++++++++++
string utag
$curfield = upper($curfield)

if $curform:backtab = TRUE then
    if utag = "C" then
        jrorddt.setFocus()
    end if

end if

return

// ------------
 
 
// ppljrdesmodeent_1 (fpl)
// ++++++++++++
save field $curfield
return

// ------------
 
 
// ppljrdesmodeext_1 (fpl)
// ++++++++++++
string mssg
if IsNull($curfield)  &
OR $curfield:savedvalue = $curfield then
    return
end if

$curfield = upper($curfield)

if (mychannel:open = FALSE) then
end if

select *
from desmodemst
where dmno = $curfield


if (mychannel:count = 0) then
    mssg = "Invalid Input ..."

    MessageBox ("Please_Note", mssg)
    this.setFocus()
    SetNull($curfield)

end if

return

// ------------
 
 
// ppljrbktabset_1 (fpl)
// ++++++++++++
long sflag
// /* for Spares no check */
if sflag = 1 then
    return
end if

if $curform:backtab = FALSE then
    bkflag = 0

else
    bkflag = 1

end if

return

// ------------
 
 
// ppljrcnddtext_1 (fpl)
// ++++++++++++
string mssg
if IsNull($curfield) then
    return
end if

if ($curfield <= jrorddt) then
    mssg = "ERROR ! Smaller than order dt"

    MessageBox ("Please_Note", mssg)
    SetNull($curfield)
    this.setFocus()

end if

return

// ------------
 
 
// ppljrotsrecvdtent_1 (fpl)
// ++++++++++++
string utag
if utag = "C" then
    jrdrvval.setFocus()
end if

// /*
//     save field $curfield
// 
//     if (jrorddt is NULL)
//     begin
//          if (bkflag = 0)
//              positionform jrbmrecvdt
//          else
//              positionform jrcondeldt
//     end
// */
return

// ------------
 
 
// ppljrbktabset_1 (fpl)
// ++++++++++++
long sflag
// /* for Spares no check */
if sflag = 1 then
    return
end if

if $curform:backtab = FALSE then
    bkflag = 0

else
    bkflag = 1

end if

return

// ------------
 
 
// ppljrotsrecvdtext_1 (fpl)
// ++++++++++++
string mssg
long sflag
if IsNull($curfield) then
// /* for spares no check for BM Recv dt */
    if sflag = 0 then
        SetNull(jrbmrecvdt)
    end if

    SetNull(jrindreledt)
    return

end if

if $curfield < jrorddt then
    mssg = "Error ! Smaller than Order Dt"

    MessageBox ("Please_Note", mssg)
    SetNull($curfield)
    this.setFocus()

end if

return

// ------------
 
 
// ppljrbmrecvdtent_1 (fpl)
// ++++++++++++
long sflag
// /* for Spares no check */
if sflag = 1 then
    return
end if

save field $curfield
if (IsNull(jrotsrecvdt)) then
    if (bkflag = 0) then
        jrpumpmodel.setFocus()
    else
        jrotsrecvdt.setFocus()
    end if

end if

return

// ------------
 
 
// ppljrbktabset_1 (fpl)
// ++++++++++++
long sflag
// /* for Spares no check */
if sflag = 1 then
    return
end if

if $curform:backtab = FALSE then
    bkflag = 0

else
    bkflag = 1

end if

return

// ------------
 
 
// ppljrbmrecvdtext_1 (fpl)
// ++++++++++++
string mssg
datetime bmdt
long sflag
if IsNull($curfield) then
    SetNull(jrindreledt)
    return

end if

// /* for Spares no check */
if sflag = 1 then
    return
end if

if ($curfield < jrotsrecvdt) then
    mssg = "ERROR ! Smaller than OTS recv dt"

    MessageBox ("Please_Note", mssg)
    $curfield = $curfield:savedvalue

    this.setFocus()
    return

end if

bmdt = $curfield

return

// ------------
 
 
// ppljrbktabset_1 (fpl)
// ++++++++++++
long sflag
// /* for Spares no check */
if sflag = 1 then
    return
end if

if $curform:backtab = FALSE then
    bkflag = 0

else
    bkflag = 1

end if

return

// ------------
 
 
// jobregmodlentr_1 (fpl)
// ++++++++++++
if substring(jrjobno,13,1) = "S" then
    jrpumpcat.setFocus()
end if

return

// ------------
 
 
// pplpmodel1_1 (fpl)
// ++++++++++++
string mssg
string mpmodel1
string mpmodel2
string mpmodel3
long lpmodel1
// /* FOR HORIZENTAL PUMP */
if substring(jrjobno,1,1) = "H" then
    jrpumpmodel = pmodel1 + pmodel2 + pmodel3

else
// /* FOR VERTICAL PUMP */
end if

if (mychannel:open = FALSE) then
end if

if NOT IsNull(pmodel1) then
    select ltrim(rtrim(pmodel1))

    into pmodel1

    from dual


end if

if NOT IsNull(pmodel1) then
    select char_length(pmodel1)

    into lpmodel1

    from dual


end if

if (mychannel:open = TRUE) then
end if

if IsNull(pmodel1) then
    lpmodel1 = 0

end if

pmodel1 = substring("  ",1,2-lpmodel1) + pmodel1

jrpumpmodel = pmodel1 + "-" + pmodel2 + "-" + pmodel3


return

// ------------
 
 
// pplpmodel2_1 (fpl)
// ++++++++++++
string mssg
string mpmodel1
string mpmodel2
string mpmodel3
long lpmodel1
// /* FOR HORIZENTAL PUMP */
if substring(jrjobno,1,1) = "H" then
    jrpumpmodel = pmodel1 + pmodel2 + pmodel3

else
// /* FOR VERTICAL PUMP */
end if

if (mychannel:open = FALSE) then
end if

if NOT IsNull(pmodel2) then
    select ltrim(rtrim(pmodel2))

    into pmodel2

    from dual


end if

if NOT IsNull(pmodel2) then
    select char_length(pmodel2)

    into lpmodel1

    from dual


end if

if (mychannel:open = TRUE) then
end if

if IsNull(pmodel2) then
    lpmodel1 = 0

end if

pmodel2 = substring("  ",1,2-lpmodel1) + pmodel2

jrpumpmodel = pmodel1 + "-" + pmodel2 + "-" + pmodel3


return

// ------------
 
 
// pplpmodel3_1 (fpl)
// ++++++++++++
long lpmodel1
pmodel1 = upper(pmodel1)

pmodel2 = upper(pmodel2)

$curfield = upper($curfield)

// /* FOR HORIZENTAL PUMP */
if substring(jrjobno,1,1) = "H" then
    jrpumpmodel = pmodel1 + pmodel2 + pmodel3

else
    jrpumpmodel = pmodel1 + "-" + pmodel2 + "-" + pmodel3

end if

return

// ------------
 
 
// jobregcatext_1 (fpl)
// ++++++++++++
if $curform:backtab = TRUE then
    if substring(jrjobno,13,1) = "S" then
        jrbmrecvdt.setFocus()
    end if

    return

end if

return

// ------------
 
 
// ppljrindreledtent_1 (fpl)
// ++++++++++++
if IsNull(jrbmrecvdt) then
    if $curform:backtab = FALSE then
        jrdrvval.setFocus()
    else
        jrpumpcat.setFocus()
    end if

end if

return

// ------------
 
 
// ppljrindreledtext_1 (fpl)
// ++++++++++++
string mssg
if IsNull($curfield) then
    return
end if

if ($curfield < jrbmrecvdt) then
    mssg = "ERROR ! Smaller than BM recv dt"

    MessageBox ("Please_Note", mssg)
    $curfield = $curfield:savedvalue

    this.setFocus()

end if

return

// ------------
 
 
// ppljobregqtyexit_1 (fpl)
// ++++++++++++
int qty
long mflag
long sflag
long pflag
string mssg
qty = jrqty

if IsNull($curfield) then
    mssg = "Please Enter Quantity ..."

    MessageBox ("Please_Note", mssg)

end if

return

// ------------
 
 
// ppljcdrvvalentr_1 (fpl)
// ++++++++++++
long sflag
if (IsNull(jrqty))  &
AND (sflag <> 1) then
    jrqty.setFocus()
end if

return

// ------------
 
 
// ppljrdrvvalext_1 (fpl)
// ++++++++++++
decimal drvrate
string utag
if $curform:backtab = TRUE then
    if utag = "C" then
        jrcondeldt.setFocus()
    end if

end if

drvrate = jrdrvval / jrqty

return

// ------------
 
 
// ppljobdespvalexit_1 (fpl)
// ++++++++++++
decimal pmprate
long sflag
decimal sprval
decimal pmpval
if sflag <> 1 then
    pmprate = jrpmpval / jrqty

    pmpval = jrpmpval


else
    sprval = $curfield

end if

return

// ------------
 
 
// ppljrmndtvalext_1 (fpl)
// ++++++++++++
decimal mndtval
long mflag
mndtval = $curfield

if IsNull(mndtval) then
    mndtval = 0

end if

mflag = 1

return

// ------------
 
 
// ppljobregjrinspext_1 (fpl)
// ++++++++++++
$curfield = upper($curfield)

return

// ------------
 
 
// ppljrcalljp_1 (fpl)
// ++++++++++++
long sflag
string utag
// /* BM Recv date */
datetime gjrbmrecvdt
// /* Order date */
datetime gjrorddt
string mssg
if utag = "C" then
    mssg = "You are not Authorised..."

    MessageBox ("Please_Note", mssg)
    return

end if

// /*
// /* Ord Dt not given */
if IsNull(jrorddt) then
    mssg = "Order Date Not Entered"

    MessageBox ("Please_Note", mssg)
    return

end if

//  */
if IsNull(jrpmpval) then
    mssg = "Pump Value not Entered ..."

    MessageBox ("Please_Note", mssg)
    return

end if

if NOT IsNull(jrjobno) then
// /* Not Spares Job */
    if sflag = 0 then
        gjrorddt = jrorddt

        callform ppljobpln_1

    else
        gjrbmrecvdt = jrbmrecvdt

// /* BM Recv date must for Spares */
        if IsNull(jrbmrecvdt) then
            mssg = "B/M Recv. Date Not Entered"

            MessageBox ("Please_Note", mssg)

        else
            callform ppljobsprpln_1
        end if


    end if


else
    mssg = "JOB Number Not Entered ..."

    MessageBox ("Please_Note", mssg)

end if

return

// ------------
 
 
// ppljrcalljc_1 (fpl)
// ++++++++++++
long jcflag
long sflag
string utag
string mssg
if utag = "C" then
    mssg = "You are not Authorised ..."

    MessageBox ("Please_Note", mssg)
    return

end if

// /*
// /* Ord Dt or BM Dt not given */
if IsNull(jrorddt)  &
OR IsNull(jrbmrecvdt) then
    mssg = "Order Dt/ BM recv.Dt Not Entered"

    MessageBox ("Please_Note", mssg)
    return

end if

//     */
// /* BM Dt not given */
if IsNull(jrbmrecvdt) then
    mssg = "BM recv.Dt Not Entered"

    MessageBox ("Please_Note", mssg)
    return

end if

if (mychannel:open = FALSE) then
end if

SetNull(mychannel:errors)
select *
from tmpjobpln


if NOT IsNull(mychannel:errors)  &
OR mychannel:count = 0 then
    mssg = "Despatch Plan not entered"

    MessageBox ("Please_Note", mssg)
    return

end if

if (mychannel:open = TRUE) then
end if

if jcflag = 1 then
// /*  callform ppljobcomp_1(jrmndtval,jrpmpval)*/
end if

// /* Not Spares Job */
if sflag = 0 then
    callform ppljobcomp_1 (jrmndtval, jrpmpval)
else
    callform ppljobcomps_1 (jrmndtval, jrpmpval)
end if


return

// ------------
 
 
// ppljrcalljd_1 (fpl)
// ++++++++++++
long jdflag
long sflag
string utag
string mssg
if utag = "C" then
    mssg = "You are not Authorised ..."

    MessageBox ("Please_Note", mssg)
    return

end if

// /*
// /* Ord Dt or BM Dt not given */
if IsNull(jrorddt)  &
OR IsNull(jrbmrecvdt) then
    mssg = "Order Dt/ BM recv.Dt Not Entered"

    MessageBox ("Please_Note", mssg)
    return

end if

//     */
// /* BM Dt not given */
if IsNull(jrbmrecvdt) then
    mssg = "BM recv.Dt Not Entered"

    MessageBox ("Please_Note", mssg)
    return

end if

if (mychannel:open = FALSE) then
end if

SetNull(mychannel:errors)
select *
from tmpjobpln


if NOT IsNull(mychannel:errors)  &
OR mychannel:count = 0 then
    mssg = "Despatch Plan not entered"

    MessageBox ("Please_Note", mssg)
    return

end if

if (mychannel:open = TRUE) then
end if

if jdflag = 1 then
// /* Not Spares Job */
    if sflag = 0 then
        callform ppljobdesp_1
    else
        callform ppljobdesps_1
    end if


end if

return

// ------------
 
 
// pplsprlstsl_1 (fpl)
// ++++++++++++
long sflag
string mssg
string slno
string jobno
if sflag <> 1 then
    return
end if

if mychannel:open = FALSE then
end if

SetNull(mychannel:errors)
select convert(char(6), jrslno)
, jrjobno

into slno, jobno

from jobreg
where jrslno in (select max(jrslno)

from jobreg
where jrslno < 9000
)


mssg = "Sl:" + slno + "  Job :" + jobno

MessageBox ("Please_Note", mssg)
return

// ------------
 
 
// ppljrconsdet_1 (fpl)
// ++++++++++++
if NOT IsNull(jrjobno) then
    callform ppljrconsdet_1 (jrordplby, jrconsdet)
end if

return

// ------------
 
 
// ppljobchngfcall_1 (fpl)
// ++++++++++++
callform ppljobchng_1 (jrjobno)
return

// ------------
 
 
