'NEW_CUST - temp. holding program for new estimates/orders routines

'!!!!!!!!!!!!!! ?select SHOP user is dealing with

EXTERNAL	sch scw userid cpath dpath messboxwait() fentrybox() vloadif() messbox() fgp bgp
EXTERNAL	navrecs() messline() popuplist() Background()

PUBLIC	ptstr abbrv_name jobnr ptval

GLOBAL	ReturnToMenu() $jobstr EnterCustName() fentline x custname $newcust custcode y1 y2
GLOBAL	$origin $msg custaddr1 H_tel O_tel ESTIMATE_Menu() ORDER_Menu() CONTACT_Menu()
GLOBAL	OFFICE_Menu() EOD_Menu() REPORTS_Menu() OTHER_Menu() WORK_Menu()


MAIN
local m1 m2 m3 m4
message "userid is:"&str(userid)
	if userid=="DAVIDC" or userid=="DAVIDG" or userid=="NSYMDS"
		m1 = "˙˙˙Work˙"
		m2 = "˙˙Office"
		m3 = "˙˙Restart"
		m4 = "˙˙˙EXIT˙"
 		x = popuplist(9,30,13,m1&m2&m3&m4,"{Esc} to exit",1,0) ' reinstate when new format used
' 		x = popuplist(9,30,13,m1&m2,"{Esc} to exit",1,0)
		if x = 0
			if ptstr = m1                   ' coming back in
				WORK_Menu()
			elseif ptstr=m2
				OFFICE_Menu()
			elseif ptstr=m3
				messboxwait(" Not yet in use ",0,0,1)
			elseif ptstr=m4
				messboxwait(" Not yet in use ",0,0,1)
			end if
		elseif x=-1
	 		ReturnToMenu()
		end if
	else
		messboxwait(" Module not yet in use ",0,0,1)
		ReturnToMenu()
	end if

' ReturnToMenu()

END MAIN


FUNCTION WORK_Menu()
local w1 w2 w3
	Background()
	file unload all
	w1 = "˙Contacts"
	w2 = "Estimates"
	w3 = "˙˙Orders"
	x = popuplist(9,30,13,w1&w2&w3,"{Esc} to exit",1,0)
	if x = 0
		if ptstr = w1                   '
			CONTACT_Menu()
		elseif ptstr=w2
			ESTIMATE_Menu()
		elseif ptstr=w3
			ORDER_Menu()
		elseif x=-1
	 		return(-1)
		end if
	end if
END FUNCTION ' WORK_Menu()


FUNCTION OFFICE_Menu()
local o1 o2 o3
	Background()
	file unload all
	o1 = "End˙of˙Day"
	o2 = "˙Reports"
	o3 = "˙˙Other"
	x = popuplist(9,30,13,o1&o2&o3,"{Esc} to exit",1,0)
	if x = 0
		if ptstr = o1                   '
			EOD_Menu()
		elseif ptstr=o2
			REPORTS_Menu()
		elseif ptstr=o3
			OTHER_Menu()
		elseif x=-1
	 		return(-1)
		end if
	end if
END FUNCTION ' OFFICE_Menu()


FUNCTION CONTACT_Menu()
local c1 c2 c3 c4 c5 c6 c7
	Background()
	file unload all
 	EnterCustName()
	c1 = "Update Contact˙details"
	c2 = "˙˙˙˙Send˙samples"
	c3 = "˙˙Arrange˙Measure"
	c4 = "˙˙˙˙˙Send˙Email"
	c5 = "˙˙˙Send˙Statement"
	c6 = "˙˙Select˙ESTIMATE"
	c7 = "˙˙˙˙Select˙ORDER"
	x = popuplist(9,30,13,c1&c2&c3&c4&c5&c6&c7,"{Esc} to exit",1,0) ' reinstate when new format used
	if x=0
	elseif x=-1
		return (-1)
     end if
END FUNCTION ' CONTACTMenu()


FUNCTION ESTIMATE_Menu()
local e1 e2 e3
	Background()
	file unload all
	e1 = "Create˙Estimate"
	e2 = "Update˙Estimate"
	e3 = "Convert˙Estimate"
	x = popuplist(9,30,13,e1&e2&e3,"{Esc} to exit",1,0)
	if x = 0
		if ptstr = e1                   '
' 			EOD_Menu()
		elseif ptstr=e2
' 			REPORTS_Menu()
		elseif ptstr=e3
' 			OTHER_Menu()
		elseif x=-1
	 		return(-1)
		end if
	end if
END FUNCTION ' ESTIMATE_Menu()


FUNCTION ORDER_Menu()
local r1 r2 r3 r4 r5 r6 r7 r8 r9
	Background()
	file unload all
	r1 = "˙Appointments"
	r2 = "˙Order˙details"
	r3 = "˙Requisitions"
	r4 = "˙Reservations"
	r5 = "˙Cash˙received"
	r6 = "˙˙˙Comments"
	r7 = "Variation˙Order"
	r8 = "˙˙Alter˙Slots"
	r9 = "˙Order˙Status"
	x = popuplist(9,30,13,r1&r2&r3&r4&r5&r6&r7&r8&r9,"{Esc} to exit",1,0) ' reinstate when new format used
	if x=0
	elseif x=-1
		return (-1)
     end if
END FUNCTION ' ORDER_Menu()


FUNCTION EOD_Menu()
local d1 d2 d3
	Background()
	file unload all
	d1 = "˙Daily˙Routine"
	d2 = "Banking˙Summary"
	d3 = "˙˙Completions"
	x = popuplist(9,30,13,d1&d2&d3,"{Esc} to exit",1,0)
	if x = 0
		if ptstr = d1                   '
' 			EOD_Menu()
		elseif ptstr=d2
' 			REPORTS_Menu()
		elseif ptstr=d3
' 			OTHER_Menu()
		elseif x=-1
	 		return(-1)
		end if
	end if
END FUNCTION ' EOD_Menu()


FUNCTION REPORTS_Menu()
local p1 p2 p3 p4 p5
	Background()
	file unload all
	p1 = "˙Aged˙Debtors"
	p2 = "˙Monthly˙Orders"
	p3 = "˙Monthly˙Sales"
	p4 = "˙Order˙Confirmation"
	p5 = "˙Archived˙Sales"
' 	r6 = "˙˙˙Comments"
' 	r7 = "Variation˙Order"
' 	r8 = "˙˙Alter˙Slots"
' 	r9 = "˙Order˙Status"
	x = popuplist(9,30,13,p1&p2&p3&p4&p5,"{Esc} to exit",1,0) ' reinstate when new format used
	if x=0
	elseif x=-1
		return (-1)
     end if
END FUNCTION ' REPORTS_Menu()


FUNCTION OTHER_Menu()
local t1 t2 t3 t4 t5 t6 t7
	Background()
	file unload all
	t1 = "˙Petty˙Cash"
	t2 = "˙Stock˙Prices"
	t3 = "˙Stockholding"
	t4 = "˙Stock˙Orders"
	t5 = "˙Fitters"
 	t6 = "˙Fitters'˙payments"
 	t7 = "Convert˙Imperial/Metric"
' 	r8 = "˙˙Alter˙Slots"
' 	r9 = "˙Order˙Status"
	x = popuplist(9,30,13,t1&t2&t3&t4&t5&t6&t7,"{Esc} to exit",1,0) ' reinstate when new format used
	if x=0
	elseif x=-1
		return (-1)
     end if
END FUNCTION ' OTHER_Menu()


FUNCTION EnterCustName()
  while true
    while true
      x = fentrybox(fentline,35,"","")
      if x = 0
        if ptstr = ""
          continue while
        end if
        exit while
      elseif x = -1
        return (-1)
      end if
    end while
    custname = ptstr
    vloadif(dpath|"custsel4.vw")
    order change key [Abbrv_Name]
    abbrv_name = proper(left(custname,7))
    data find "[Abbrv_Name]" equal abbrv_name options ""
    if cerror
      messbox(" Name not on file, is"&chr(34)|custname|chr(34)|" a new customer? (y/n)",1,0,1)
      if ptstr == "y"
        $newcust = "Y"
        custcode = jobnr
        return (0)
      end if
    end if
    vloadif(dpath|"custsel4.vw")

    repaint on
    repaint
    ptval=0
    y1 = format(" CONTACTS ALREADY HELD ON FILE ","M71")
    y2 = format(" {A}dd"&chr(34)|custname|chr(34)|" - {S}elect highlight - {Esc} exits ","M71")
    screen print 4 6 fgp bgp y1
    screen print 21 6 fgp bgp y2
    while true
      ptval = navrecs()
      if ptval = {S} or ptval = {s}
        if (deleted)
          messboxwait(" Deleted record - choose another ",0,0,1)
          continue while
        end if
        $origin  = [Source]            ' message "$origin is:"&str($origin)
        $newcust = "N"
        custname = [Customer_Name]
        abbrv_name = [Abbrv_Name]
        if len([Address_1]) <> 0       ' Same name
          $msg = custname&"of"&[Address_1]|"?" 'message "len($msg)) is:"&str(len($msg))
          messbox($msg,1,1,1)
          if ptstr == "y"
            custcode  = [Customer_Code]
'             $parent   = [Parent]
            custaddr1 = [Address_1]
            H_tel     = [Home_Tel]
            O_tel     = [Office_Tel]
          else
            y2 = format(" {A}dd"&chr(34)|custname|chr(34)|" - {S}elect highlight - {Esc} exits ","M71")
            screen print 21 6 fgp bgp y2
            continue while
          end if
          repaint off
MESSAGE "updsate details?"
          return (0)
        else                           'if [Address_1] > 0
        end if

      elseif ptval = {A} or ptval = {a}
        messline(" Add"&chr(34)|custname|chr(34)&"to list of Customers? (y/n)",1,1,1,21,6,71)
        if ptstr ! "y"
          $newcust = "Y"
          if x = 0
            exit while
          end if
        else
          exit while
        end if
        repaint off
        return (0)

      elseif ptval = {Esc}
        return (-1)
      end if
    end while
  end while
END FUNCTION 'EnterCustName()




' message "Show CUST history screen"		
' history screen has hotkey options for;
' CUSTOMER options
' 		 updating details
' 		 sending samples
' 		 arranging measure
' 		 sending email
' 		 selecting ESTIMATE record for further processing
' 		 selecting CustOrd record for further processing

'		 ESTIMATE options
' 			 producing estimate
'			 converting estimate to order

'		 CUSTOMER ORDER options
' 			 arranging fitting
' 			 entering order details
' 			 entering reservations
' 			 entering reqns
' 			 entering cash
' 			 enter comment

FUNCTION ReturnToMenu()
  Background()
  file unload all
  fopen dpath|userid|".jnr" as 1
  fwrite 1 from $jobstr
  fclose 1
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()


