<!doctype html>
<html>

<head>
  <base href="/">
  <script src="/dmxAppConnect/dmxAppConnect.js"></script>
  <meta charset="UTF-8">
  <title>RPM Industries</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="stylesheet" href="/bootstrap/5/css/bootstrap.min.css" />
  <link rel="stylesheet" href="/css/style.css" />
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js" integrity="sha256-CutOzxCRucUsn6C6TcEYsauvvYilEniTXldPa6/wu0k=" crossorigin="anonymous"></script>
  <script src="/dmxAppConnect/dmxRouting/dmxRouting.js" defer></script>
  <script src="/dmxAppConnect/dmxDataTraversal/dmxDataTraversal.js" defer></script>
  <script src="/dmxAppConnect/dmxTyped/dmxTyped.js" defer></script>
  <script src="/dmxAppConnect/dmxTyped/typed.min.js" defer></script>
  <link rel="stylesheet" href="/dmxAppConnect/dmxValidator/dmxValidator.css" />
  <script src="/dmxAppConnect/dmxValidator/dmxValidator.js" defer></script>
  <link rel="stylesheet" href="/dmxAppConnect/dmxNotifications/dmxNotifications.css" />
  <script src="/dmxAppConnect/dmxNotifications/dmxNotifications.js" defer></script>
  <script src="/dmxAppConnect/dmxBrowser/dmxBrowser.js" defer></script>
  <script src="/dmxAppConnect/dmxBootstrap5Navigation/dmxBootstrap5Navigation.js" defer></script>
  <script src="/dmxAppConnect/dmxFormatter/dmxFormatter.js" defer></script>
  <script src="/dmxAppConnect/dmxStateManagement/dmxStateManagement.js" defer></script>
  <script src="/dmxAppConnect/dmxFormRepeat/dmxFormRepeat.js" defer></script>
  <link rel="stylesheet" href="/dmxAppConnect/dmxBootstrap5TableGenerator/dmxBootstrap5TableGenerator.css" />
  <script src="/dmxAppConnect/dmxBootstrap5Modal/dmxBootstrap5Modal.js" defer></script>
  <script src="/dmxAppConnect/dmxScheduler/dmxScheduler.js" defer></script>
  <script src="/dmxAppConnect/dmxBootstrap5Toasts/dmxBootstrap5Toasts.js" defer></script>
  <script src="/socket.io/socket.io.js" defer></script>
  <script src="/dmxAppConnect/dmxSockets/dmxSockets.js" defer></script>
  <script src="/dmxAppConnect/dmxDatastore/dmxDatastore.js" defer></script>
  <link rel="stylesheet" href="/dmxAppConnect/dmxDatePicker/daterangepicker.min.css" />
  <script src="/dmxAppConnect/dmxDatePicker/daterangepicker.min.js" defer></script>
  <link rel="stylesheet" href="/dmxAppConnect/dmxDatePicker/dmxDatePicker.css" />
  <script src="/dmxAppConnect/dmxDatePicker/dmxDatePicker.js" defer></script>


  <link rel="stylesheet" href="/dmxAppConnect/dmxAutocomplete/dmxAutocomplete.css" />
  <script src="/dmxAppConnect/dmxAutocomplete/dmxAutocomplete.js" defer></script>
  <script src="/dmxAppConnect/dmxBootbox5/bootstrap-modbox.min.js" defer></script>
  <script src="/dmxAppConnect/dmxBootbox5/dmxBootbox5.js" defer></script>
  <script src="/dmxAppConnect/dmxBootstrap5Alert/dmxBootstrap5Alert.js" defer></script>
  <link rel="stylesheet" href="/fontawesome6/css/all.min.css" />
  <script src="/dmxAppConnect/dmxBootstrap4Navigation/dmxBootstrap4Navigation.js" defer></script>
  <script src="/dmxAppConnect/dmxBootstrap4Modal/dmxBootstrap4Modal.js" defer></script>
  <link rel="stylesheet" href="/dmxAppConnect/dmxBootstrap4TableGenerator/dmxBootstrap4TableGenerator.css" />
</head>

<body is="dmx-app" id="main">
  <dmx-value id="var_ptsearch" dmx-on:updated="conn_search.load({},true)"></dmx-value>
  <dmx-value id="var_partid"></dmx-value>
  <dmx-value id="var_userinfo"></dmx-value>
  <dmx-value id="pg_apiurl" dmx-bind:value="conn_urls.data.apiurl"></dmx-value>
  <dmx-serverconnect id="viewsearch" noload="true" url="/api/PartCodes/parent" dmx-on:success="run({condition:{outputType:'boolean',if:`(viewsearch.data.view == \'change\')`,then:{steps:{run:{outputType:'text',action:`mod_changepartcode.show()`}}},else:{steps:{run:{outputType:'text',action:`browser1.goto(\'/\'+viewsearch.data.view+\'?id=\'+var_partid.value)`}}}}})"></dmx-serverconnect>
  <dmx-serverconnect id="whoami" url="/api/security/whoami"></dmx-serverconnect>
  <dmx-serverconnect id="conn_basedata" url="/api/Parts/newpartbasedata"></dmx-serverconnect>
  <dmx-serverconnect id="conn_urls" url="/api/gs/urls"></dmx-serverconnect>
  <dmx-serverconnect id="conn_isauthenticated" url="/api/security/isauthenticated" dmx-on:forbidden="browser1.goto('/cnfrm',true)" dmx-on:unauthorized="browser1.goto('/',true)"></dmx-serverconnect>
  <dmx-serverconnect id="conn_logout" url="/api/security/logout" dmx-on:success="browser1.goto('/')" noload="true"></dmx-serverconnect>
  <dmx-serverconnect id="conn_newpart" url="/api/Parts/asynccalls/create_part" noload="true" dmx-param:description="modal_newpart.inp_description.value" dmx-param:comments="modal_newpart.inp_comments.value" dmx-param:partcodeid="" dmx-param:parttypeid="modal_newpart.new_parttype.value" dmx-on:success="run([{run:{outputType:'text',action:`var_partid.setValue(conn_newpart.data.createpartnumber.data.id)`}},{run:{name:'conn_view',outputType:'text',action:`viewsearch.load({id: conn_newpart.data.createpartnumber.data.partcode.id},true)`}}])" dmx-param:createuserid="conn_isauthenticated.data.identity"></dmx-serverconnect>
  <dmx-serverconnect id="conn_searchforbom" url="/api/BOM/findbypn" noload="true"></dmx-serverconnect>
  <dmx-serverconnect id="conn_search" url="/api/Parts/Seach" dmx-param:input="var_ptsearch.value" noload="true"></dmx-serverconnect>
  <dmx-serverconnect id="conn_masterpcs" url="/api/PartCodes/masters"></dmx-serverconnect>
  <dmx-serverconnect id="conn_cmasters" url="/api/PartCodes/cmasters" dmx-param:code="mod_createpart.frm_createpart.inp_masterpc.value" noload="true"></dmx-serverconnect>
  <div is="dmx-browser" id="browser1"></div>
  <div class="modal" id="mod_changepartcode" is="dmx-bs5-modal" tabindex="-1">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title">Part Code Invalid</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <div class="form-group mb-3 row">
            <label for="inp_masterpc" class="col-sm-2 col-form-label col-form-label-sm" style="width: 30%">Top Part Code</label>
            <div class="align-self-center col-sm-7 offset-1">
              <input type="text" class="form-control" id="inp_masterpc" name="masterpartcode" aria-describedby="input1_help" is="dmx-autocomplete" dmx-bind:data="conn_masterpcs.data.list.data" optiontext="name" optionvalue="code" optionsearch="name+' '" dmx-on:changed="run({condition:{outputType:'boolean',if:`value`,then:{steps:{run:{outputType:'text',action:`conn_cmasters.load({code: value},true)`}}}}})">
            </div>
          </div>
          <div class="form-group mb-3 row" dmx-hide="inp_masterpc.value">
            <label for="inp_childpc" class="col-sm-2 col-form-label col-form-label-sm" style="width: 30%">Part Code</label>
            <div class="align-self-center col-sm-7 offset-1">
              <input type="text" class="form-control" id="inp_childpc" name="childpartcode" aria-describedby="input1_help" is="dmx-autocomplete" dmx-bind:data="conn_masterpcs.data.allpartcodes.data" optiontext="name" optionvalue="code" optionsearch="name+' '">
            </div>
          </div>
          <div class="form-group mb-3 row" dmx-show="inp_masterpc.value">
            <label for="inp_filteredchildpc" class="col-sm-2 col-form-label col-form-label-sm" style="width: 30%">Part Code</label>
            <div class="align-self-center col-sm-7 offset-1">
              <input type="text" class="form-control" id="inp_filteredchildpc" name="filteredchildpartcode" aria-describedby="input1_help" is="dmx-autocomplete" dmx-bind:data="conn_cmasters.data.api.data" optiontext="name" optionvalue="code" optionsearch="name+' '">
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary">Save changes</button>
        </div>
      </div>
    </div>
  </div>
  <div class="modal" id="mod_createpart" is="dmx-bs5-modal" tabindex="-1">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title">New Part</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <form id="frm_createpart">
            <div class="form-group mb-3 row">
              <label for="inp_masterpc" class="col-sm-2 col-form-label col-form-label-sm" style="width: 30%">Top Part Code</label>
              <div class="align-self-center col-sm-7 offset-1">
                <input type="text" class="form-control" id="inp_masterpc" name="masterpartcode" aria-describedby="input1_help" is="dmx-autocomplete" dmx-bind:data="conn_masterpcs.data.list.data" optiontext="name" optionvalue="code" optionsearch="name+' '" dmx-on:changed="run({condition:{outputType:'boolean',if:`value`,then:{steps:{run:{outputType:'text',action:`conn_cmasters.load({code: value},true)`}}}}})">
              </div>
            </div>
            <div class="form-group mb-3 row" dmx-hide="inp_masterpc.value">
              <label for="inp_childpc" class="col-sm-2 col-form-label col-form-label-sm" style="width: 30%">Part Code</label>
              <div class="align-self-center col-sm-7 offset-1">
                <input type="text" class="form-control" id="inp_childpc" name="childpartcode" aria-describedby="input1_help" is="dmx-autocomplete" dmx-bind:data="conn_masterpcs.data.allpartcodes.data" optiontext="name" optionvalue="code" optionsearch="name+' '">
              </div>
            </div>
            <div class="form-group mb-3 row" dmx-show="inp_masterpc.value">
              <label for="inp_filteredchildpc" class="col-sm-2 col-form-label col-form-label-sm" style="width: 30%">Part Code</label>
              <div class="align-self-center col-sm-7 offset-1">
                <input type="text" class="form-control" id="inp_filteredchildpc" name="filteredchildpartcode" aria-describedby="input1_help" is="dmx-autocomplete" dmx-bind:data="conn_cmasters.data.api.data" optiontext="name" optionvalue="code" optionsearch="name+' '">
              </div>
            </div>
          </form>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary" dmx-on:click="run({condition:{outputType:'boolean',if:`(frm_createpart.inp_masterpc.value.length() &gt; 0)`,then:{steps:{run:{outputType:'text',action:`conn_newpart.load({partcodeid: conn_masterpcs.data.allpartcodes.data.where(\`code\`, frm_createpart.inp_filteredchildpc.value, \'==\')[0].id, code: frm_createpart.inp_filteredchildpc.value})`}}},else:{steps:{run:{outputType:'text',action:`conn_newpart.load({partcodeid: conn_masterpcs.data.allpartcodes.data.where(\`code\`, frm_createpart.inp_childpc.value, \'==\')[0].id, code: frm_createpart.inp_childpc.value})`}}}}})">Save changes</button>
        </div>
      </div>
    </div>
  </div>

  <div class="container d-print-none" style="vertial-align: middle;">


    <nav class="navbar navbar-expand-lg navbar-dark bg-primary align-items-center">
      <div class="container-fluid">
        <a class="navbar-brand" href="#">RPM Studio</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar1_collapse" aria-controls="navbar1_collapse" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
        <div class="collapse navbar-collapse" id="navbar1_collapse">
          <div class="navbar-nav">

            <a class="nav-item nav-link active" href="/partinfo">Home</a>
            <div class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" id="dropdown1" role="button" aria-haspopup="true" aria-expanded="false">Actions</a>
              <div class="dropdown-menu" aria-labelledby="dropdown1">
                <a class="dropdown-item" internal="true" dmx-on:click="mod_createpart.show()">New Part</a>
                <a class="dropdown-item" href="/wadmin/usermanage" id="lnk_admin" dmx-show="conn_isauthenticated.data.administrator">User Management</a>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </div>
            <div class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbar1_dropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account&nbsp;</a>
              <div class="dropdown-menu" aria-labelledby="navbar1_dropdown">
                <a class="dropdown-item" href="#" dmx-on:click="conn_logout.load({});browser1.goto('/')">Logout</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="#">Account</a>
              </div>
            </div>
          </div>
        </div>
        <p style="float: right;" class="text-white fw-bold" dmx-text="'Welcome '+whoami.data.query.firstname+' '+whoami.data.query.lastname"></p>
      </div>
    </nav>
  </div>
  <div class="modal" id="modal_newpart" is="dmx-bs5-modal" tabindex="-1">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title">New Part</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
          <div class="container">
            <div class="row">
              <div class="col">

                <div class="form-group mb-3 row">
                  <label for="inp_masterpc" class="col-sm-2 col-form-label" style="width: fit-content;">Part Types</label>
                  <select id="new_parttype" class="form-select" style="width: fit-content;" dmx-bind:options="conn_basedata.data.parttypes.data" optiontext="name" optionvalue="id">
                    <option value="0"></option>
                  </select>
                </div>
                <div class="form-group mb-3 row">
                  <label for="inp_masterpc" class="col-sm-2 col-form-label" style="width: fit-content;">Part Codes</label>
                  <select id="new_partcode" class="form-select" style="width: fit-content;" dmx-bind:options="conn_basedata.data.partcodes.data.where(`parttype.id`, new_parttype.value, '==')" optiontext="name" optionvalue="id">
                    <option value="0"></option>
                  </select>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col">
                <div class="form-group mb-3 row">
                  <label for="inp_description" class="col-sm-2 col-form-label">Description</label>
                  <div class="col-sm-10">
                    <textarea id="inp_description" class="form-control" name="description"></textarea>
                  </div>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col">
                <div class="form-group mb-3 row">
                  <label for="inp_comments" class="col-sm-2 col-form-label">Comments</label>
                  <div class="col-sm-10">
                    <textarea id="inp_comments" class="form-control" name="comments"></textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
          <button type="button" class="btn btn-primary" dmx-on:click="conn_newpart.load({})">
            Save changes</button>
        </div>
      </div>
    </div>
  </div>
  <div is="dmx-view" id="content">
    <%- await include(content, locals); %>
  </div>
  <script src="/bootstrap/5/js/bootstrap.bundle.min.js"></script>
</body>

</html>