{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare subroutine forward_event, security_err_msg\r\ndeclare function company_comm, msg, security_check, post_event, rowexists\r\ndeclare function fieldcount, send_event, scroll_enable\r\n$insert logical\r\n$insert security_rights_equ\r\n$insert msg_equates\r\n$insert order_equ\r\n\r\n\r\nNewRecord = false$\r\nif rowexists( 'SCHEDULE', .schedule_no->text ) then\r\n   ReadOk = true$\r\nend else\r\n   * user is trying to add new don't allow ( only create via order )\r\n   MsgInfo = ''\r\n   MsgInfo<mtext$> = 'You can only create schedules from order.'\r\n   MsgInfo<micon$> = 'H'\r\n   Void = msg( '', MsgInfo )\t  \r\n   ReadOk = false$\r\n   .schedule_no->text = ''\r\n   Void = post_event( CtrlEntId, 'CLEAR', False$, True$ )\r\nend\r\nif ReadOk then\r\n   if get_property( @window, '@NoRead' ) then\r\n       Void = set_property( @window, '@NoRead', 0 )\r\n   end else\r\n       * no qbf active do the read\r\n       * if it is active the read already took place\r\n       forward_event()\r\n   end\r\n   ****************\r\n   Tcust = .cust_no->text\r\n   if ( Tcust = '615' ) or ( Tcust = '6443' ) or ( Tcust = 621 ) then ;* FIRST TWO ARE PHILIPS AND LAST IS SSI\r\n       .qxj->visible = 1\r\n   end else\r\n       .qxj->visible = 0\r\n   end\r\n   ****************\r\n   ScheduleNo = .schedule_no->text\r\n   ProtectVar = 'PO/ENTRY_ID/ENTRY_DATE/CUST_NO/CUST_NAME/'\r\n   ProtectVar:= 'WO/WAFER_SIZE/QUOTE_NO/RDS_CNT/ORDER_NO/TOT_SCHED/TOT_NOT_SCHED/'\r\n   ProtectVar:= 'TOTAL_SHIP_QTY/TOTAL_REJECTS/TOTAL_NOT_SHIP_QTY/TOTAL_SHIP_AMOUNT/SEP_LAYER_CNT/'\r\n   ProtectVar:= 'BOX_COUNT/TOT_WAF_IN/PSN'\r\n   swap '/' with @rm:@window:'.' in ProtectVar\r\n   ProtectVar = @window:'.':ProtectVar\r\n   Void = set_property( ProtectVar, 'ENABLED', 0 ) \r\n   * add all other protected fields\r\n   if rowexists( 'SCHEDULE', ScheduleNo ) else\r\n      .entry_id->text = oconv( @user4, '[XLATE_CONV,LSL_USERS*FIRST_LAST]' )\r\n      .entry_date->text = oconv( date(), 'D2/' )   \r\n   end  \r\n   Void = set_property( @window, '@OrigRDSDetail', .rds_detail->array )          \r\n   if NewRecord else\r\n\t   if security_check( 'Schedule', Edit$ ) then\r\n\t      RdsDetail   = .rds_detail->array\r\n\t      RDSCol      = RdsDetail<2>\r\n\t      OrderDetail = .order_detail_line->array\r\n\t      Qty         = OrderDetail<6>\r\n\t      if RDSCol = @vm:@vm:@vm and ( Qty > 0 and Qty < 26 ) then ;* meaning there have been no rds createdare no rds \r\n\t         OrderRec = xlate( 'ORDER', .order_no->text, '', 'X' )\r\n\t         Wo = .wo->text\r\n             OrderWos = OrderRec<order_wo$>\r\n             OrderQty = OrderRec<order_quantity$>\r\n             OrderLineNo = OrderDetail<1>\r\n             WoHitCnt = 0\r\n             if OrderLineNo = 1 then\r\n                 * do nothing, cause you know it is run order one\r\n             end else\r\n\t             OrderWos = field( OrderWos, @vm, 1, OrderLineNo-1 )\r\n\t             * TAKE ALL ORDER LINES PRIOR TO THIS ONE AND COUNT HOW MANY TIMES THAT \r\n\t             * WORK ORDER IS FOUND AND ADD ONE AND THAT IS YOUR RUN ORDER\r\n\t             OlCnt = fieldcount( OrderWos, @vm )\r\n\t             for i = 1 to OlCnt\r\n\t                if ( OrderWos<1,i> = Wo ) and ( OrderQty<1,i> > 0 ) then\r\n\t                   WoHitCnt += 1\r\n\t                end\r\n\t             next i\r\n\t         end\r\n             * ADD ONE TO WOHITCNT FOR THE NEXT RUN ORDER\r\n             WoHitCnt += 1\r\n             NewRdsDetail = WoHitCnt:@fm:@fm:Qty\r\n             .rds_detail->array = NewRdsDetail\r\n             .date_wafers_received->text = oconv( date(), 'D2/' )\r\n             WSS = .wafer_sched_ship->array\r\n             WSS<1,1> = Qty\r\n             .wafer_sched_ship->array = WSS\r\n             *\r\n             * SET THE CALCULATED FIELDS MANUALLY IT IS JUST AS EASY\r\n             .tot_waf_in->text    = Qty\r\n             .tot_sched->text     = Qty\r\n             .tot_not_sched->text = 0\r\n             * SET FOCUS TO THE RDS DETAIL\r\n             Void = set_property( @window:'.RDS_DETAIL', 'FOCUS', 1 )\r\n             Void = post_event( @window:'.RDS_DETAIL', 'GOTFOCUS' )\r\n             .rds_detail->selpos = 1:@fm:1\r\n             @@window->savewarn = 1\r\n\t      end\r\n\t   end else\r\n\t      * protect all fields\r\n\t      AllControls = utility( 'OBJECTLIST', @window, '' )\r\n\t      Acnt = fieldcount( AllControls, @fm )     \r\n\t      for i = 1 to Acnt         \r\n\t         ThisControl = AllControls<i>\r\n\t         if ThisControl[-6,6] = '_LABEL' or index( ThisControl, 'MENU', 1 ) or index( ThisControl, 'TEXT', 1 ) else\r\n\t            void = set_property( ThisControl, 'ENABLED', 0 )\r\n\t         end           \r\n\t      next i   \r\n          Void = scroll_enable()\t         \t      \t      \r\n\t   end\r\n   end\r\nend\r\nRETURN 0"
        }
    }
}