<html><head><title>/doc/plugins/type/</title></head>
<body>
<h2>/doc/plugins/type/</h2>
<ul>
<li><a href='/ikiwiki-upstream/plain/doc/plugins/?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>../</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/auth.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>auth.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/bundle.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>bundle.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/chrome.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>chrome.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/core.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>core.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/date.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>date.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/format.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>format.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/fun.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>fun.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/html.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>html.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/link.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>link.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/meta.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>meta.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/slow.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>slow.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/special-purpose.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>special-purpose.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/tags.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>tags.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/web.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>web.mdwn</a></li>
  <li><a href='/ikiwiki-upstream/plain/doc/plugins/type/widget.mdwn?id=192ce7a238af9021b0fd6dd571f22409af81ebaf'>widget.mdwn</a></li>
 </ul>
</body></html>
'>diff</a></td><td class='form'><form class='right' method='get' action='/ledger-smb/log/LedgerSMB/JC.pm'>
<input type='hidden' name='h' value='1.2.16+jones'/><input type='hidden' name='id' value='82faef9e9f3d3a46705f0000ffd4006ae8b6cf0c'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/ledger-smb/tree/?h=1.2.16%2bjones&amp;id=82faef9e9f3d3a46705f0000ffd4006ae8b6cf0c'>root</a>/<a href='/ledger-smb/tree/LedgerSMB?h=1.2.16%2bjones&amp;id=82faef9e9f3d3a46705f0000ffd4006ae8b6cf0c'>LedgerSMB</a>/<a href='/ledger-smb/tree/LedgerSMB/JC.pm?h=1.2.16%2bjones&amp;id=82faef9e9f3d3a46705f0000ffd4006ae8b6cf0c'>JC.pm</a></div><div class='content'>blob: 2f3bf9dc5ace48868d88eccc9509667948e53231 (<a href='/ledger-smb/plain/LedgerSMB/JC.pm?h=1.2.16%2bjones&amp;id=82faef9e9f3d3a46705f0000ffd4006ae8b6cf0c'>plain</a>)
<table summary='blob content' class='blob'>
<tr>
<td class='lines'><pre><code><ol class="hl">
<li id="n_1" class="hl"><span class="hl slc">#=====================================================================</span></li>
<li id="n_2" class="hl"><span class="hl slc">#&nbsp;LedgerSMB</span></li>
<li id="n_3" class="hl"><span class="hl slc"># Small Medium Business Accounting software</span></li>
<li id="n_4" class="hl"><span class="hl slc"># http://www.ledgersmb.org/</span></li>
<li id="n_5" class="hl"><span class="hl slc">#</span></li>
<li id="n_6" class="hl"><span class="hl slc"># Copyright (C) 2006</span></li>
<li id="n_7" class="hl"><span class="hl slc"># This work contains copyrighted information from a number of sources all used</span></li>
<li id="n_8" class="hl"><span class="hl slc"># with permission.</span></li>
<li id="n_9" class="hl"><span class="hl slc">#</span></li>
<li id="n_10" class="hl"><span class="hl slc"># This file contains source code included with or based on SQL-Ledger which</span></li>
<li id="n_11" class="hl"><span class="hl slc"># is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed</span></li>
<li id="n_12" class="hl"><span class="hl slc"># under the GNU General Public License version 2 or, at your option, any later</span></li>
<li id="n_13" class="hl"><span class="hl slc"># version.  For a full list including contact information of contributors,</span></li>
<li id="n_14" class="hl"><span class="hl slc"># maintainers, and copyright holders, see the CONTRIBUTORS file.</span></li>
<li id="n_15" class="hl"><span class="hl slc">#</span></li>
<li id="n_16" class="hl"><span class="hl slc"># Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):</span></li>
<li id="n_17" class="hl"><span class="hl slc"># Copyright (C) 2005</span></li>
<li id="n_18" class="hl"><span class="hl slc">#</span></li>
<li id="n_19" class="hl"><span class="hl slc">#  Author: DWS Systems Inc.</span></li>
<li id="n_20" class="hl"><span class="hl slc">#     Web: http://www.sql-ledger.org</span></li>
<li id="n_21" class="hl"><span class="hl slc">#</span></li>
<li id="n_22" class="hl"><span class="hl slc">#  Contributors:</span></li>
<li id="n_23" class="hl"><span class="hl slc">#</span></li>
<li id="n_24" class="hl"><span class="hl slc">#======================================================================</span></li>
<li id="n_25" class="hl"><span class="hl slc">#</span></li>
<li id="n_26" class="hl"><span class="hl slc"># This file has undergone whitespace cleanup.</span></li>
<li id="n_27" class="hl"><span class="hl slc">#</span></li>
<li id="n_28" class="hl"><span class="hl slc">#======================================================================</span></li>
<li id="n_29" class="hl"><span class="hl slc">#</span></li>
<li id="n_30" class="hl"><span class="hl slc"># Job Costing</span></li>
<li id="n_31" class="hl"><span class="hl slc">#</span></li>
<li id="n_32" class="hl"><span class="hl slc">#======================================================================</span></li>
<li id="n_33" class="hl"></li>
<li id="n_34" class="hl"><span class="hl kwa">package </span>JC<span class="hl opt">;</span></li>
<li id="n_35" class="hl"></li>
<li id="n_36" class="hl"><span class="hl kwa">use </span>LedgerSMB<span class="hl opt">::</span>IS<span class="hl opt">;</span></li>
<li id="n_37" class="hl"><span class="hl kwa">use </span>LedgerSMB<span class="hl opt">::</span>PriceMatrix<span class="hl opt">;</span></li>
<li id="n_38" class="hl"><span class="hl kwa">use </span>LedgerSMB<span class="hl opt">::</span>Sysconfig<span class="hl opt">;</span></li>
<li id="n_39" class="hl"></li>
<li id="n_40" class="hl"><span class="hl kwa">sub </span>get_jcitems <span class="hl opt">{</span></li>
<li id="n_41" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form </span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_42" class="hl"></li>
<li id="n_43" class="hl">    <span class="hl slc"># connect to database</span></li>
<li id="n_44" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_45" class="hl"></li>
<li id="n_46" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT current_date<span class="hl opt">|;</span></li>
<li id="n_47" class="hl">    <span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">} ) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_48" class="hl"></li>
<li id="n_49" class="hl">    <span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee_id<span class="hl opt">} ) = </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">get_employee</span><span class="hl opt">(</span><span class="hl kwb">$dbh</span><span class="hl opt">);</span></li>
<li id="n_50" class="hl"></li>
<li id="n_51" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dateformat </span><span class="hl opt">= </span><span class="hl kwb">$myconfig</span><span class="hl opt">-&gt;{</span>dateformat<span class="hl opt">};</span></li>
<li id="n_52" class="hl">    <span class="hl kwb">$dateformat </span><span class="hl opt">=~ </span><span class="hl kwd">s/yy/yyyy/</span><span class="hl opt">;</span></li>
<li id="n_53" class="hl">    <span class="hl kwb">$dateformat </span><span class="hl opt">=~ </span><span class="hl kwd">s/yyyyyy/yyyy/</span><span class="hl opt">;</span></li>
<li id="n_54" class="hl"></li>
<li id="n_55" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} ) {</span></li>
<li id="n_56" class="hl"></li>
<li id="n_57" class="hl">        <span class="hl slc"># retrieve timecard/storescard</span></li>
<li id="n_58" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_59" class="hl">            SELECT j<span class="hl opt">.*, </span>to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, </span><span class="hl sng">&#39;HH24:MI:SS&#39;</span><span class="hl opt">) </span></li>
<li id="n_60" class="hl">                   AS checkedina<span class="hl opt">, </span></li>
<li id="n_61" class="hl">                   to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedout<span class="hl opt">, </span><span class="hl sng">&#39;HH24:MI:SS&#39;</span><span class="hl opt">) </span></li>
<li id="n_62" class="hl">                   AS checkedouta<span class="hl opt">, </span></li>
<li id="n_63" class="hl">                   to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, ?) </span>AS transdate<span class="hl opt">,</span></li>
<li id="n_64" class="hl">                   e<span class="hl opt">.</span>name AS employee<span class="hl opt">, </span>p<span class="hl opt">.</span>partnumber<span class="hl opt">,</span></li>
<li id="n_65" class="hl">                   pr<span class="hl opt">.</span>projectnumber<span class="hl opt">, </span></li>
<li id="n_66" class="hl">                   pr<span class="hl opt">.</span>description AS projectdescription<span class="hl opt">,</span></li>
<li id="n_67" class="hl">                   pr<span class="hl opt">.</span>production<span class="hl opt">, </span>pr<span class="hl opt">.</span>completed<span class="hl opt">, </span></li>
<li id="n_68" class="hl">                   pr<span class="hl opt">.</span>parts_id AS project</li>
<li id="n_69" class="hl">              FROM jcitems j</li>
<li id="n_70" class="hl">              JOIN employee e ON <span class="hl opt">(</span>e<span class="hl opt">.</span>id <span class="hl opt">= </span>j<span class="hl opt">.</span>employee_id<span class="hl opt">)</span></li>
<li id="n_71" class="hl">              JOIN parts p ON <span class="hl opt">(</span>p<span class="hl opt">.</span>id <span class="hl opt">= </span>j<span class="hl opt">.</span>parts_id<span class="hl opt">)</span></li>
<li id="n_72" class="hl">              JOIN project pr ON <span class="hl opt">(</span>pr<span class="hl opt">.</span>id <span class="hl opt">= </span>j<span class="hl opt">.</span>project_id<span class="hl opt">)</span></li>
<li id="n_73" class="hl">             WHERE j<span class="hl opt">.</span>id <span class="hl opt">= ?|;</span></li>
<li id="n_74" class="hl">        <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_75" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$dateformat</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} )</span></li>
<li id="n_76" class="hl">          <span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_77" class="hl"></li>
<li id="n_78" class="hl">        <span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">);</span></li>
<li id="n_79" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">db_parse_numeric</span><span class="hl opt">(</span>sth<span class="hl opt">=&gt;</span><span class="hl kwb">$sth</span><span class="hl opt">, </span>hashref<span class="hl opt">=&gt;</span><span class="hl kwb">$ref</span><span class="hl opt">);</span></li>
<li id="n_80" class="hl"></li>
<li id="n_81" class="hl">        <span class="hl kwa">for </span><span class="hl opt">( </span><span class="hl kwc">keys </span><span class="hl kwb">%$ref </span><span class="hl opt">) { </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} }</span></li>
<li id="n_82" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_83" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} = ( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} ) ? </span><span class="hl sng">&quot;job&quot;</span> <span class="hl opt">: </span><span class="hl sng">&quot;project&quot;</span><span class="hl opt">;</span></li>
<li id="n_84" class="hl">        <span class="hl kwa">for </span><span class="hl opt">(</span><span class="hl sng">qw(checkedin checkedout)</span><span class="hl opt">) {</span></li>
<li id="n_85" class="hl">            <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} = </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;${_}a&quot;</span><span class="hl opt">};</span></li>
<li id="n_86" class="hl">            <span class="hl kwc">delete </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl sng">&quot;${_}a&quot;</span><span class="hl opt">};</span></li>
<li id="n_87" class="hl">        <span class="hl opt">}</span></li>
<li id="n_88" class="hl"></li>
<li id="n_89" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_90" class="hl">            SELECT s<span class="hl opt">.</span>printed<span class="hl opt">, </span>s<span class="hl opt">.</span>spoolfile<span class="hl opt">, </span>s<span class="hl opt">.</span>formname</li>
<li id="n_91" class="hl">              FROM status s</li>
<li id="n_92" class="hl">             WHERE s<span class="hl opt">.</span>formname <span class="hl opt">= ?</span></li>
<li id="n_93" class="hl">                   AND s<span class="hl opt">.</span>trans_id <span class="hl opt">= ?|;</span></li>
<li id="n_94" class="hl">        <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_95" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} )</span></li>
<li id="n_96" class="hl">          <span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_97" class="hl"></li>
<li id="n_98" class="hl">        <span class="hl kwa">while </span><span class="hl opt">( </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">) ) {</span></li>
<li id="n_99" class="hl">            <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>printed<span class="hl opt">} .= </span><span class="hl sng">&quot;</span><span class="hl ipl">$ref</span><span class="hl sng">-&gt;{formname} &quot;</span></li>
<li id="n_100" class="hl">              <span class="hl kwa">if </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>printed<span class="hl opt">};</span></li>
<li id="n_101" class="hl">            <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>queued<span class="hl opt">} .= </span><span class="hl sng">&quot;</span><span class="hl ipl">$ref</span><span class="hl sng">-&gt;{formname} </span><span class="hl ipl">$ref</span><span class="hl sng">-&gt;{spoolfile} &quot;</span></li>
<li id="n_102" class="hl">              <span class="hl kwa">if </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>spoolfile<span class="hl opt">};</span></li>
<li id="n_103" class="hl">        <span class="hl opt">}</span></li>
<li id="n_104" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_105" class="hl">        <span class="hl kwa">for </span><span class="hl opt">(</span><span class="hl sng">qw(printed queued)</span><span class="hl opt">) { </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} =~ </span><span class="hl kwd">s/ +$//g </span><span class="hl opt">}</span></li>
<li id="n_106" class="hl">    <span class="hl opt">}</span></li>
<li id="n_107" class="hl"></li>
<li id="n_108" class="hl">    JC-<span class="hl opt">&gt;</span><span class="hl kwd">jcitems_links</span><span class="hl opt">( </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">, </span><span class="hl kwb">$dbh </span><span class="hl opt">);</span></li>
<li id="n_109" class="hl"></li>
<li id="n_110" class="hl">    <span class="hl slc"># get language codes</span></li>
<li id="n_111" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT <span class="hl opt">* </span>FROM language ORDER BY <span class="hl num">2</span><span class="hl opt">|;</span></li>
<li id="n_112" class="hl">    <span class="hl kwb">$sth   </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_113" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_114" class="hl"></li>
<li id="n_115" class="hl">    <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>all_language<span class="hl opt">} = ();</span></li>
<li id="n_116" class="hl">    <span class="hl kwa">while </span><span class="hl opt">( </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">) ) {</span></li>
<li id="n_117" class="hl">        <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>all_language<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_118" class="hl">    <span class="hl opt">}</span></li>
<li id="n_119" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_120" class="hl"></li>
<li id="n_121" class="hl">    <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">commit</span><span class="hl opt">;</span></li>
<li id="n_122" class="hl"></li>
<li id="n_123" class="hl"><span class="hl opt">}</span></li>
<li id="n_124" class="hl"></li>
<li id="n_125" class="hl"><span class="hl kwa">sub </span>jcitems_links <span class="hl opt">{</span></li>
<li id="n_126" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">, </span><span class="hl kwb">$dbh </span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_127" class="hl"></li>
<li id="n_128" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$disconnect </span><span class="hl opt">= </span><span class="hl num">0</span><span class="hl opt">;</span></li>
<li id="n_129" class="hl"></li>
<li id="n_130" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( !</span><span class="hl kwb">$dbh </span><span class="hl opt">) {</span></li>
<li id="n_131" class="hl">        <span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_132" class="hl">    <span class="hl opt">}</span></li>
<li id="n_133" class="hl"></li>
<li id="n_134" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$query</span><span class="hl opt">;</span></li>
<li id="n_135" class="hl"></li>
<li id="n_136" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project_id<span class="hl opt">} ) {</span></li>
<li id="n_137" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>orphaned<span class="hl opt">} = </span><span class="hl num">1</span><span class="hl opt">;</span></li>
<li id="n_138" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT parts_id<span class="hl opt">, </span>customer_id FROM project WHERE id <span class="hl opt">= ?|;</span></li>
<li id="n_139" class="hl">        <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_140" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project_id<span class="hl opt">} );</span></li>
<li id="n_141" class="hl">        <span class="hl opt">(</span><span class="hl kwb">$parts_id</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>customer_id<span class="hl opt">} ) = </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array </span><span class="hl opt">;</span></li>
<li id="n_142" class="hl">        <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$parts_id </span><span class="hl opt">) {</span></li>
<li id="n_143" class="hl">            <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} = </span><span class="hl sng">&#39;job&#39;</span><span class="hl opt">;</span></li>
<li id="n_144" class="hl">            <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_145" class="hl">                SELECT id</li>
<li id="n_146" class="hl">                  FROM project</li>
<li id="n_147" class="hl">                 WHERE parts_id <span class="hl opt">&gt; </span><span class="hl num">0</span></li>
<li id="n_148" class="hl">                       AND production <span class="hl opt">&gt; </span>completed</li>
<li id="n_149" class="hl">                       AND id <span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project_id<span class="hl opt">}|;</span></li>
<li id="n_150" class="hl">            <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_151" class="hl">            <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project_id<span class="hl opt">} );</span></li>
<li id="n_152" class="hl">            <span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>orphaned<span class="hl opt">} ) = </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array</span><span class="hl opt">();</span></li>
<li id="n_153" class="hl">            <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_154" class="hl">        <span class="hl opt">}</span></li>
<li id="n_155" class="hl">        <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_156" class="hl">            <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} = </span><span class="hl sng">&#39;project&#39;</span><span class="hl opt">;</span></li>
<li id="n_157" class="hl">        <span class="hl opt">}</span></li>
<li id="n_158" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_159" class="hl">    <span class="hl opt">}</span></li>
<li id="n_160" class="hl"></li>
<li id="n_161" class="hl">    JC-<span class="hl opt">&gt;</span><span class="hl kwd">jcparts</span><span class="hl opt">( </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">, </span><span class="hl kwb">$dbh </span><span class="hl opt">);</span></li>
<li id="n_162" class="hl"></li>
<li id="n_163" class="hl">    <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">all_employees</span><span class="hl opt">( </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$dbh</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">} );</span></li>
<li id="n_164" class="hl"></li>
<li id="n_165" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$where</span><span class="hl opt">;</span></li>
<li id="n_166" class="hl"></li>
<li id="n_167" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">} ) {</span></li>
<li id="n_168" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">.= </span>qq<span class="hl opt">| </span></li>
<li id="n_169" class="hl">            AND <span class="hl opt">(</span>enddate IS NULL</li>
<li id="n_170" class="hl">                OR enddate <span class="hl opt">&gt;= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">} ) . </span>qq<span class="hl opt">|)</span></li>
<li id="n_171" class="hl">            AND <span class="hl opt">(</span>startdate <span class="hl opt">&lt;= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">} ) . </span>qq<span class="hl opt">|</span></li>
<li id="n_172" class="hl">                OR startdate IS NULL<span class="hl opt">)|;</span></li>
<li id="n_173" class="hl">    <span class="hl opt">}</span></li>
<li id="n_174" class="hl"></li>
<li id="n_175" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;job&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_176" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_177" class="hl">            SELECT pr<span class="hl opt">.*</span></li>
<li id="n_178" class="hl">              FROM project pr</li>
<li id="n_179" class="hl">             WHERE pr<span class="hl opt">.</span>parts_id <span class="hl opt">&gt; </span><span class="hl num">0</span></li>
<li id="n_180" class="hl">                   AND pr<span class="hl opt">.</span>production <span class="hl opt">&gt; </span>pr<span class="hl opt">.</span>completed</li>
<li id="n_181" class="hl">                   <span class="hl kwb">$where</span><span class="hl opt">|;</span></li>
<li id="n_182" class="hl">    <span class="hl opt">}</span></li>
<li id="n_183" class="hl">    <span class="hl kwa">elsif </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;project&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_184" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_185" class="hl">            SELECT pr<span class="hl opt">.*</span></li>
<li id="n_186" class="hl">              FROM project pr</li>
<li id="n_187" class="hl">             WHERE pr<span class="hl opt">.</span>parts_id IS NULL</li>
<li id="n_188" class="hl">                   <span class="hl kwb">$where</span><span class="hl opt">|;</span></li>
<li id="n_189" class="hl">    <span class="hl opt">}</span></li>
<li id="n_190" class="hl">    <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_191" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_192" class="hl">            SELECT pr<span class="hl opt">.*</span></li>
<li id="n_193" class="hl">              FROM project pr</li>
<li id="n_194" class="hl">             WHERE <span class="hl num">1</span><span class="hl opt">=</span><span class="hl num">1</span></li>
<li id="n_195" class="hl">                   <span class="hl kwb">$where</span></li>
<li id="n_196" class="hl">            EXCEPT</li>
<li id="n_197" class="hl">            SELECT pr<span class="hl opt">.*</span></li>
<li id="n_198" class="hl">              FROM project pr</li>
<li id="n_199" class="hl">             WHERE pr<span class="hl opt">.</span>parts_id <span class="hl opt">&gt; </span><span class="hl num">0</span></li>
<li id="n_200" class="hl">                   AND pr<span class="hl opt">.</span>production <span class="hl opt">= </span>pr<span class="hl opt">.</span>completed<span class="hl opt">|;</span></li>
<li id="n_201" class="hl">    <span class="hl opt">}</span></li>
<li id="n_202" class="hl"></li>
<li id="n_203" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project_id<span class="hl opt">} ) {</span></li>
<li id="n_204" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">.= </span>qq<span class="hl opt">|</span></li>
<li id="n_205" class="hl">            UNION</li>
<li id="n_206" class="hl">            SELECT <span class="hl opt">*</span></li>
<li id="n_207" class="hl">              FROM project</li>
<li id="n_208" class="hl">             WHERE id <span class="hl opt">= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project_id<span class="hl opt">} );</span></li>
<li id="n_209" class="hl">    <span class="hl opt">}</span></li>
<li id="n_210" class="hl"></li>
<li id="n_211" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span>qq<span class="hl opt">|</span></li>
<li id="n_212" class="hl">                 ORDER BY projectnumber<span class="hl opt">|;</span></li>
<li id="n_213" class="hl"></li>
<li id="n_214" class="hl">    <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_215" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_216" class="hl"></li>
<li id="n_217" class="hl">    <span class="hl kwa">while </span><span class="hl opt">( </span><span class="hl kwc">my </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">) ) {</span></li>
<li id="n_218" class="hl">        <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>all_project<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_219" class="hl">    <span class="hl opt">}</span></li>
<li id="n_220" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_221" class="hl"><span class="hl opt">}</span></li>
<li id="n_222" class="hl"></li>
<li id="n_223" class="hl"><span class="hl kwa">sub </span>jcparts <span class="hl opt">{</span></li>
<li id="n_224" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">, </span><span class="hl kwb">$dbh </span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_225" class="hl"></li>
<li id="n_226" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$project_id </span><span class="hl opt">) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>projectnumber<span class="hl opt">};</span></li>
<li id="n_227" class="hl">    <span class="hl kwb">$project_id </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">(</span><span class="hl kwb">$project_id</span><span class="hl opt">);</span></li>
<li id="n_228" class="hl"></li>
<li id="n_229" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT customer_id FROM project WHERE id <span class="hl opt">= </span><span class="hl kwb">$project_id</span><span class="hl opt">|;</span></li>
<li id="n_230" class="hl">    <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$customer_id</span><span class="hl opt">) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_231" class="hl">    <span class="hl kwb">$customer_id </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">(</span><span class="hl kwb">$customer_id</span><span class="hl opt">);</span></li>
<li id="n_232" class="hl"></li>
<li id="n_233" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$where</span><span class="hl opt">;</span></li>
<li id="n_234" class="hl"></li>
<li id="n_235" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;job&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_236" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">= </span><span class="hl sng">&quot; AND p.income_accno_id IS NULL&quot;</span><span class="hl opt">;</span></li>
<li id="n_237" class="hl">        <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;storescard&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_238" class="hl">            <span class="hl kwb">$where </span><span class="hl opt">= </span><span class="hl sng">&quot; AND p.inventory_accno_id &gt; 0</span></li>
<li id="n_239" class="hl"><span class="hl sng">                       AND p.income_accno_id &gt; 0&quot;</span><span class="hl opt">;</span></li>
<li id="n_240" class="hl">        <span class="hl opt">}</span></li>
<li id="n_241" class="hl"></li>
<li id="n_242" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_243" class="hl">               SELECT p<span class="hl opt">.</span>id<span class="hl opt">, </span>p<span class="hl opt">.</span>partnumber<span class="hl opt">, </span>p<span class="hl opt">.</span>description<span class="hl opt">, </span></li>
<li id="n_244" class="hl">                      p<span class="hl opt">.</span>sellprice<span class="hl opt">,</span></li>
<li id="n_245" class="hl">                      p<span class="hl opt">.</span>unit<span class="hl opt">, </span>t<span class="hl opt">.</span>description AS translation</li>
<li id="n_246" class="hl">                 FROM parts p</li>
<li id="n_247" class="hl">            LEFT JOIN translation t </li>
<li id="n_248" class="hl">                      ON <span class="hl opt">(</span>t<span class="hl opt">.</span>trans_id <span class="hl opt">= </span>p<span class="hl opt">.</span>id </li>
<li id="n_249" class="hl">                      AND t<span class="hl opt">.</span>language_code </li>
<li id="n_250" class="hl">                      <span class="hl opt">= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>language_code<span class="hl opt">} ) . </span>qq<span class="hl opt">|)</span></li>
<li id="n_251" class="hl">                WHERE p<span class="hl opt">.</span>obsolete <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_252" class="hl">                      <span class="hl kwb">$where</span><span class="hl opt">|;</span></li>
<li id="n_253" class="hl">    <span class="hl opt">}</span></li>
<li id="n_254" class="hl">    <span class="hl kwa">elsif </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;project&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_255" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">= </span><span class="hl sng">&quot; AND p.inventory_accno_id IS NULL&quot;</span><span class="hl opt">;</span></li>
<li id="n_256" class="hl">        <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;storescard&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_257" class="hl">            <span class="hl kwb">$where </span><span class="hl opt">= </span><span class="hl sng">&quot; AND p.inventory_accno_id &gt; 0&quot;</span><span class="hl opt">;</span></li>
<li id="n_258" class="hl">        <span class="hl opt">}</span></li>
<li id="n_259" class="hl"></li>
<li id="n_260" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_261" class="hl">               SELECT p<span class="hl opt">.</span>id<span class="hl opt">, </span>p<span class="hl opt">.</span>partnumber<span class="hl opt">, </span>p<span class="hl opt">.</span>description<span class="hl opt">, </span></li>
<li id="n_262" class="hl">                      p<span class="hl opt">.</span>sellprice<span class="hl opt">, </span>p<span class="hl opt">.</span>unit<span class="hl opt">, </span></li>
<li id="n_263" class="hl">                      t<span class="hl opt">.</span>description AS translation </li>
<li id="n_264" class="hl">                 FROM parts p </li>
<li id="n_265" class="hl">            LEFT JOIN translation t </li>
<li id="n_266" class="hl">                      ON <span class="hl opt">(</span>t<span class="hl opt">.</span>trans_id <span class="hl opt">= </span>p<span class="hl opt">.</span>id </li>
<li id="n_267" class="hl">                      AND t<span class="hl opt">.</span>language_code </li>
<li id="n_268" class="hl">                      <span class="hl opt">= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>language_code<span class="hl opt">} ) . </span>qq<span class="hl opt">|)</span></li>
<li id="n_269" class="hl">                WHERE p<span class="hl opt">.</span>obsolete <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_270" class="hl">                      AND p<span class="hl opt">.</span>assembly <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span> <span class="hl kwb">$where</span><span class="hl opt">|;</span></li>
<li id="n_271" class="hl">    <span class="hl opt">}</span></li>
<li id="n_272" class="hl">    <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_273" class="hl"></li>
<li id="n_274" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_275" class="hl">               SELECT p<span class="hl opt">.</span>id<span class="hl opt">, </span>p<span class="hl opt">.</span>partnumber<span class="hl opt">, </span>p<span class="hl opt">.</span>description<span class="hl opt">, </span></li>
<li id="n_276" class="hl">                      p<span class="hl opt">.</span>sellprice<span class="hl opt">, </span>p<span class="hl opt">.</span>unit<span class="hl opt">, </span></li>
<li id="n_277" class="hl">                      t<span class="hl opt">.</span>description AS translation</li>
<li id="n_278" class="hl">                 FROM parts p</li>
<li id="n_279" class="hl">            LEFT JOIN translation t </li>
<li id="n_280" class="hl">                      ON <span class="hl opt">(</span>t<span class="hl opt">.</span>trans_id <span class="hl opt">= </span>p<span class="hl opt">.</span>id </li>
<li id="n_281" class="hl">                      AND t<span class="hl opt">.</span>language_code </li>
<li id="n_282" class="hl">                      <span class="hl opt">= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>language_code<span class="hl opt">} ) . </span>qq<span class="hl opt">|)</span></li>
<li id="n_283" class="hl">                WHERE p<span class="hl opt">.</span>obsolete <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_284" class="hl">                      AND p<span class="hl opt">.</span>income_accno_id IS NULL</li>
<li id="n_285" class="hl">            UNION</li>
<li id="n_286" class="hl">               SELECT p<span class="hl opt">.</span>id<span class="hl opt">, </span>p<span class="hl opt">.</span>partnumber<span class="hl opt">, </span>p<span class="hl opt">.</span>description<span class="hl opt">, </span></li>
<li id="n_287" class="hl">                      p<span class="hl opt">.</span>sellprice<span class="hl opt">, </span>p<span class="hl opt">.</span>unit<span class="hl opt">, </span></li>
<li id="n_288" class="hl">                      t<span class="hl opt">.</span>description AS translation </li>
<li id="n_289" class="hl">                 FROM parts p </li>
<li id="n_290" class="hl">            LEFT JOIN translation t </li>
<li id="n_291" class="hl">                      ON <span class="hl opt">(</span>t<span class="hl opt">.</span>trans_id <span class="hl opt">= </span>p<span class="hl opt">.</span>id </li>
<li id="n_292" class="hl">                      AND t<span class="hl opt">.</span>language_code </li>
<li id="n_293" class="hl">                      <span class="hl opt">= | . </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>language_code<span class="hl opt">} ) . </span>qq<span class="hl opt">|)</span></li>
<li id="n_294" class="hl">                WHERE p<span class="hl opt">.</span>obsolete <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_295" class="hl">                      AND p<span class="hl opt">.</span>assembly <span class="hl opt">= </span><span class="hl sng">&#39;0&#39;</span></li>
<li id="n_296" class="hl">                      AND p<span class="hl opt">.</span>inventory_accno_id IS NULL<span class="hl opt">|;</span></li>
<li id="n_297" class="hl">    <span class="hl opt">}</span></li>
<li id="n_298" class="hl"></li>
<li id="n_299" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">.= </span>qq<span class="hl opt">|</span></li>
<li id="n_300" class="hl">         ORDER BY <span class="hl num">2</span><span class="hl opt">|;</span></li>
<li id="n_301" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_302" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute </span><span class="hl opt">|| </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_303" class="hl"></li>
<li id="n_304" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$pmh </span><span class="hl opt">= </span>PriceMatrix<span class="hl opt">::</span>price_matrix_query<span class="hl opt">( </span><span class="hl kwb">$dbh</span><span class="hl opt">, </span><span class="hl kwb">$form </span><span class="hl opt">);</span></li>
<li id="n_305" class="hl">    IS<span class="hl opt">::</span>exchangerate_defaults<span class="hl opt">( </span><span class="hl kwb">$dbh</span><span class="hl opt">, </span><span class="hl kwb">$form </span><span class="hl opt">);</span></li>
<li id="n_306" class="hl"></li>
<li id="n_307" class="hl">    <span class="hl kwa">while </span><span class="hl opt">( </span><span class="hl kwc">my </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">) ) {</span></li>
<li id="n_308" class="hl">        <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>description<span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>translation<span class="hl opt">}</span></li>
<li id="n_309" class="hl">          <span class="hl kwa">if </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>translation<span class="hl opt">};</span></li>
<li id="n_310" class="hl">        PriceMatrix<span class="hl opt">::</span>price_matrix<span class="hl opt">( </span><span class="hl kwb">$pmh</span><span class="hl opt">, </span><span class="hl kwb">$ref</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl num">4</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">,</span></li>
<li id="n_311" class="hl">            <span class="hl kwb">$myconfig </span><span class="hl opt">);</span></li>
<li id="n_312" class="hl">        <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>all_parts<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_313" class="hl">    <span class="hl opt">}</span></li>
<li id="n_314" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_315" class="hl"></li>
<li id="n_316" class="hl"><span class="hl opt">}</span></li>
<li id="n_317" class="hl"></li>
<li id="n_318" class="hl"><span class="hl kwa">sub </span>delete_timecard <span class="hl opt">{</span></li>
<li id="n_319" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form </span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_320" class="hl"></li>
<li id="n_321" class="hl">    <span class="hl slc"># connect to database</span></li>
<li id="n_322" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_323" class="hl"></li>
<li id="n_324" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">%audittrail </span><span class="hl opt">= (</span></li>
<li id="n_325" class="hl">        tablename <span class="hl opt">=&gt; </span><span class="hl sng">&#39;jcitems&#39;</span><span class="hl opt">,</span></li>
<li id="n_326" class="hl">        reference <span class="hl opt">=&gt; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">},</span></li>
<li id="n_327" class="hl">        formname  <span class="hl opt">=&gt; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">},</span></li>
<li id="n_328" class="hl">        action    <span class="hl opt">=&gt; </span><span class="hl sng">&#39;deleted&#39;</span><span class="hl opt">,</span></li>
<li id="n_329" class="hl">        id        <span class="hl opt">=&gt; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">}</span></li>
<li id="n_330" class="hl">    <span class="hl opt">);</span></li>
<li id="n_331" class="hl"></li>
<li id="n_332" class="hl">    <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">audittrail</span><span class="hl opt">( </span><span class="hl kwb">$dbh</span><span class="hl opt">, </span><span class="hl sng">&quot;&quot;</span><span class="hl opt">, </span>\<span class="hl kwb">%audittrail </span><span class="hl opt">);</span></li>
<li id="n_333" class="hl"></li>
<li id="n_334" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>DELETE FROM jcitems WHERE id <span class="hl opt">= ?|;</span></li>
<li id="n_335" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$sth   </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_336" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} ) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_337" class="hl"></li>
<li id="n_338" class="hl">    <span class="hl slc"># delete spool files</span></li>
<li id="n_339" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_340" class="hl">        SELECT spoolfile FROM status</li>
<li id="n_341" class="hl">         WHERE formname <span class="hl opt">= ?</span></li>
<li id="n_342" class="hl">               AND trans_id <span class="hl opt">= ?</span></li>
<li id="n_343" class="hl">               AND spoolfile IS NOT NULL<span class="hl opt">|;</span></li>
<li id="n_344" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_345" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} ) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_346" class="hl"></li>
<li id="n_347" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$spoolfile</span><span class="hl opt">;</span></li>
<li id="n_348" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">&#64;spoolfiles </span><span class="hl opt">= ();</span></li>
<li id="n_349" class="hl"></li>
<li id="n_350" class="hl">    <span class="hl kwa">while </span><span class="hl opt">( (</span><span class="hl kwb">$spoolfile</span><span class="hl opt">) = </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array </span><span class="hl opt">) {</span></li>
<li id="n_351" class="hl">        <span class="hl kwc">push </span><span class="hl kwb">&#64;spoolfiles</span><span class="hl opt">, </span><span class="hl kwb">$spoolfile</span><span class="hl opt">;</span></li>
<li id="n_352" class="hl">    <span class="hl opt">}</span></li>
<li id="n_353" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_354" class="hl"></li>
<li id="n_355" class="hl">    <span class="hl slc"># delete status entries</span></li>
<li id="n_356" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_357" class="hl">        DELETE </li>
<li id="n_358" class="hl">          FROM status</li>
<li id="n_359" class="hl">         WHERE formname <span class="hl opt">= ?</span></li>
<li id="n_360" class="hl">               AND trans_id <span class="hl opt">= ?|;</span></li>
<li id="n_361" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_362" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} ) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_363" class="hl"></li>
<li id="n_364" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$rc </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">commit</span><span class="hl opt">;</span></li>
<li id="n_365" class="hl"></li>
<li id="n_366" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$rc</span><span class="hl opt">) {</span></li>
<li id="n_367" class="hl">        <span class="hl kwa">foreach </span><span class="hl kwb">$spoolfile </span><span class="hl opt">(</span><span class="hl kwb">&#64;spoolfiles</span><span class="hl opt">) {</span></li>
<li id="n_368" class="hl">            <span class="hl kwc">unlink </span><span class="hl sng">&quot;${LedgerSMB::Sysconfig::spool}/</span><span class="hl ipl">$spoolfile</span><span class="hl sng">&quot;</span></li>
<li id="n_369" class="hl">              <span class="hl kwa">if </span><span class="hl kwb">$spoolfile</span><span class="hl opt">;</span></li>
<li id="n_370" class="hl">        <span class="hl opt">}</span></li>
<li id="n_371" class="hl">    <span class="hl opt">}</span></li>
<li id="n_372" class="hl"></li>
<li id="n_373" class="hl">    <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;{</span>commit<span class="hl opt">};</span></li>
<li id="n_374" class="hl"></li>
<li id="n_375" class="hl">    <span class="hl kwb">$rc</span><span class="hl opt">;</span></li>
<li id="n_376" class="hl"></li>
<li id="n_377" class="hl"><span class="hl opt">}</span></li>
<li id="n_378" class="hl"></li>
<li id="n_379" class="hl"><span class="hl kwa">sub </span>jcitems <span class="hl opt">{</span></li>
<li id="n_380" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form </span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_381" class="hl"></li>
<li id="n_382" class="hl">    <span class="hl slc"># connect to database</span></li>
<li id="n_383" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_384" class="hl"></li>
<li id="n_385" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$query</span><span class="hl opt">;</span></li>
<li id="n_386" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$where </span><span class="hl opt">= </span><span class="hl sng">&quot;1 = 1&quot;</span><span class="hl opt">;</span></li>
<li id="n_387" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$null</span><span class="hl opt">;</span></li>
<li id="n_388" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$var</span><span class="hl opt">;</span></li>
<li id="n_389" class="hl"></li>
<li id="n_390" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>projectnumber<span class="hl opt">} ) {</span></li>
<li id="n_391" class="hl">        <span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$var </span><span class="hl opt">) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>projectnumber<span class="hl opt">};</span></li>
<li id="n_392" class="hl">        <span class="hl kwb">$var </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">(</span><span class="hl kwb">$var</span><span class="hl opt">);</span></li>
<li id="n_393" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND j.project_id = </span><span class="hl ipl">$var</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_394" class="hl"></li>
<li id="n_395" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT parts_id FROM project WHERE id <span class="hl opt">= </span><span class="hl kwb">$var</span><span class="hl opt">|;</span></li>
<li id="n_396" class="hl">        <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$job</span><span class="hl opt">) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_397" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} = (</span><span class="hl kwb">$job</span><span class="hl opt">) ? </span><span class="hl sng">&quot;job&quot;</span> <span class="hl opt">: </span><span class="hl sng">&quot;project&quot;</span><span class="hl opt">;</span></li>
<li id="n_398" class="hl"></li>
<li id="n_399" class="hl">    <span class="hl opt">}</span></li>
<li id="n_400" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>partnumber<span class="hl opt">} ) {</span></li>
<li id="n_401" class="hl">        <span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$var </span><span class="hl opt">) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>partnumber<span class="hl opt">};</span></li>
<li id="n_402" class="hl">        <span class="hl kwb">$var </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">(</span><span class="hl kwb">$var</span><span class="hl opt">);</span></li>
<li id="n_403" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND j.parts_id = </span><span class="hl ipl">$var</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_404" class="hl"></li>
<li id="n_405" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_406" class="hl">            SELECT inventory_accno_id</li>
<li id="n_407" class="hl">              FROM parts</li>
<li id="n_408" class="hl">             WHERE id <span class="hl opt">= </span><span class="hl kwb">$var</span><span class="hl opt">|;</span></li>
<li id="n_409" class="hl">        <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$job</span><span class="hl opt">) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_410" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} = (</span><span class="hl kwb">$job</span><span class="hl opt">) ? </span><span class="hl sng">&quot;job&quot;</span> <span class="hl opt">: </span><span class="hl sng">&quot;project&quot;</span><span class="hl opt">;</span></li>
<li id="n_411" class="hl"></li>
<li id="n_412" class="hl">    <span class="hl opt">}</span></li>
<li id="n_413" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee<span class="hl opt">} ) {</span></li>
<li id="n_414" class="hl">        <span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$var </span><span class="hl opt">) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee<span class="hl opt">};</span></li>
<li id="n_415" class="hl">        <span class="hl kwb">$var </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">(</span><span class="hl kwb">$var</span><span class="hl opt">);</span></li>
<li id="n_416" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND j.employee_id = </span><span class="hl ipl">$var</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_417" class="hl">    <span class="hl opt">}</span></li>
<li id="n_418" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwc">open</span><span class="hl opt">} || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>closed<span class="hl opt">} ) {</span></li>
<li id="n_419" class="hl">        <span class="hl kwa">unless </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwc">open</span><span class="hl opt">} &amp;&amp; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>closed<span class="hl opt">} ) {</span></li>
<li id="n_420" class="hl">            <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND j.qty != j.allocated&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwc">open</span><span class="hl opt">};</span></li>
<li id="n_421" class="hl">            <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND j.qty = j.allocated&quot;</span></li>
<li id="n_422" class="hl">              <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>closed<span class="hl opt">};</span></li>
<li id="n_423" class="hl">        <span class="hl opt">}</span></li>
<li id="n_424" class="hl">    <span class="hl opt">}</span></li>
<li id="n_425" class="hl"></li>
<li id="n_426" class="hl">    <span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>startdatefrom<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>startdateto<span class="hl opt">} ) =</span></li>
<li id="n_427" class="hl">      <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">from_to</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>year<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>month<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>interval<span class="hl opt">} )</span></li>
<li id="n_428" class="hl">      <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>year<span class="hl opt">} &amp;&amp; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>month<span class="hl opt">};</span></li>
<li id="n_429" class="hl"></li>
<li id="n_430" class="hl">    <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND j.checkedin &gt;= &quot;</span> <span class="hl opt">. </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>startdatefrom<span class="hl opt">} )</span></li>
<li id="n_431" class="hl">      <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>startdatefrom<span class="hl opt">};</span></li>
<li id="n_432" class="hl">    <span class="hl kwb">$where </span><span class="hl opt">.=</span></li>
<li id="n_433" class="hl">      <span class="hl sng">&quot; AND j.checkedout &lt; date &quot;</span> <span class="hl opt">. </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">quote</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>startdateto<span class="hl opt">} ) . </span><span class="hl sng">&quot; + 1&quot;</span></li>
<li id="n_434" class="hl">      <span class="hl kwa">if </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>startdateto<span class="hl opt">};</span></li>
<li id="n_435" class="hl"></li>
<li id="n_436" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">%ordinal </span><span class="hl opt">= (</span></li>
<li id="n_437" class="hl">        id                 <span class="hl opt">=&gt; </span><span class="hl num">1</span><span class="hl opt">,</span></li>
<li id="n_438" class="hl">        description        <span class="hl opt">=&gt; </span><span class="hl num">2</span><span class="hl opt">,</span></li>
<li id="n_439" class="hl">        transdate          <span class="hl opt">=&gt; </span><span class="hl num">7</span><span class="hl opt">,</span></li>
<li id="n_440" class="hl">        partnumber         <span class="hl opt">=&gt; </span><span class="hl num">9</span><span class="hl opt">,</span></li>
<li id="n_441" class="hl">        projectnumber      <span class="hl opt">=&gt; </span><span class="hl num">10</span><span class="hl opt">,</span></li>
<li id="n_442" class="hl">        projectdescription <span class="hl opt">=&gt; </span><span class="hl num">11</span><span class="hl opt">,</span></li>
<li id="n_443" class="hl">    <span class="hl opt">);</span></li>
<li id="n_444" class="hl"></li>
<li id="n_445" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">&#64;a </span><span class="hl opt">= ( </span>transdate<span class="hl opt">, </span>projectnumber <span class="hl opt">);</span></li>
<li id="n_446" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$sortorder </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">sort_order</span><span class="hl opt">( </span>\<span class="hl kwb">&#64;a</span><span class="hl opt">, </span>\<span class="hl kwb">%ordinal </span><span class="hl opt">);</span></li>
<li id="n_447" class="hl"></li>
<li id="n_448" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dateformat </span><span class="hl opt">= </span><span class="hl kwb">$myconfig</span><span class="hl opt">-&gt;{</span>dateformat<span class="hl opt">};</span></li>
<li id="n_449" class="hl">    <span class="hl kwb">$dateformat </span><span class="hl opt">=~ </span><span class="hl kwd">s/yy$/yyyy/</span><span class="hl opt">;</span></li>
<li id="n_450" class="hl">    <span class="hl kwb">$dateformat </span><span class="hl opt">=~ </span><span class="hl kwd">s/yyyyyy/yyyy/</span><span class="hl opt">;</span></li>
<li id="n_451" class="hl"></li>
<li id="n_452" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;job&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_453" class="hl">        <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;timecard&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_454" class="hl">            <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; </span></li>
<li id="n_455" class="hl"><span class="hl sng">                AND pr.parts_id &gt; 0</span></li>
<li id="n_456" class="hl"><span class="hl sng">                AND p.income_accno_id IS NULL&quot;</span><span class="hl opt">;</span></li>
<li id="n_457" class="hl">        <span class="hl opt">}</span></li>
<li id="n_458" class="hl"></li>
<li id="n_459" class="hl">        <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;storescard&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_460" class="hl">            <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; </span></li>
<li id="n_461" class="hl"><span class="hl sng">                AND pr.parts_id &gt; 0</span></li>
<li id="n_462" class="hl"><span class="hl sng">                AND p.income_accno_id &gt; 0&quot;</span><span class="hl opt">;</span></li>
<li id="n_463" class="hl">        <span class="hl opt">}</span></li>
<li id="n_464" class="hl">    <span class="hl opt">}</span></li>
<li id="n_465" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} </span><span class="hl kwc">eq </span><span class="hl sng">&#39;project&#39;</span> <span class="hl opt">) {</span></li>
<li id="n_466" class="hl">        <span class="hl kwb">$where </span><span class="hl opt">.= </span><span class="hl sng">&quot; AND pr.parts_id IS NULL&quot;</span><span class="hl opt">;</span></li>
<li id="n_467" class="hl">    <span class="hl opt">}</span></li>
<li id="n_468" class="hl"></li>
<li id="n_469" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_470" class="hl">        SELECT j<span class="hl opt">.</span>id<span class="hl opt">, </span>j<span class="hl opt">.</span>description<span class="hl opt">, </span>j<span class="hl opt">.</span>qty<span class="hl opt">, </span>j<span class="hl opt">.</span>allocated<span class="hl opt">,</span></li>
<li id="n_471" class="hl">               to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, </span><span class="hl sng">&#39;HH24:MI&#39;</span><span class="hl opt">) </span>AS checkedin<span class="hl opt">,</span></li>
<li id="n_472" class="hl">               to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedout<span class="hl opt">, </span><span class="hl sng">&#39;HH24:MI&#39;</span><span class="hl opt">) </span>AS checkedout<span class="hl opt">,</span></li>
<li id="n_473" class="hl">               to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, </span><span class="hl sng">&#39;yyyymmdd&#39;</span><span class="hl opt">) </span>AS transdate<span class="hl opt">,</span></li>
<li id="n_474" class="hl">               to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, ?) </span>AS transdatea<span class="hl opt">,</span></li>
<li id="n_475" class="hl">               to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, </span><span class="hl sng">&#39;D&#39;</span><span class="hl opt">) </span>AS weekday<span class="hl opt">,</span></li>
<li id="n_476" class="hl">               p<span class="hl opt">.</span>partnumber<span class="hl opt">,</span></li>
<li id="n_477" class="hl">               pr<span class="hl opt">.</span>projectnumber<span class="hl opt">, </span>pr<span class="hl opt">.</span>description AS projectdescription<span class="hl opt">,</span></li>
<li id="n_478" class="hl">               e<span class="hl opt">.</span>employeenumber<span class="hl opt">, </span>e<span class="hl opt">.</span>name AS employee<span class="hl opt">,</span></li>
<li id="n_479" class="hl">               to_char<span class="hl opt">(</span>j<span class="hl opt">.</span>checkedin<span class="hl opt">, </span><span class="hl sng">&#39;WW&#39;</span><span class="hl opt">) </span>AS workweek<span class="hl opt">, </span>pr<span class="hl opt">.</span>parts_id<span class="hl opt">,</span></li>
<li id="n_480" class="hl">               j<span class="hl opt">.</span>sellprice</li>
<li id="n_481" class="hl">          FROM jcitems j</li>
<li id="n_482" class="hl">          JOIN parts p ON <span class="hl opt">(</span>p<span class="hl opt">.</span>id <span class="hl opt">= </span>j<span class="hl opt">.</span>parts_id<span class="hl opt">)</span></li>
<li id="n_483" class="hl">          JOIN project pr ON <span class="hl opt">(</span>pr<span class="hl opt">.</span>id <span class="hl opt">= </span>j<span class="hl opt">.</span>project_id<span class="hl opt">)</span></li>
<li id="n_484" class="hl">          JOIN employee e ON <span class="hl opt">(</span>e<span class="hl opt">.</span>id <span class="hl opt">= </span>j<span class="hl opt">.</span>employee_id<span class="hl opt">)</span></li>
<li id="n_485" class="hl">         WHERE <span class="hl kwb">$where</span></li>
<li id="n_486" class="hl">        ORDER BY employee<span class="hl opt">, </span>employeenumber<span class="hl opt">, </span><span class="hl kwb">$sortorder</span><span class="hl opt">|;</span></li>
<li id="n_487" class="hl"></li>
<li id="n_488" class="hl">    <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_489" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$dateformat</span><span class="hl opt">) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_490" class="hl"></li>
<li id="n_491" class="hl">    <span class="hl kwa">while </span><span class="hl opt">( </span><span class="hl kwb">$ref </span><span class="hl opt">= </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_hashref</span><span class="hl opt">(</span>NAME_lc<span class="hl opt">) ) {</span></li>
<li id="n_492" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">db_parse_numeric</span><span class="hl opt">(</span>sth<span class="hl opt">=&gt;</span><span class="hl kwb">$sth</span><span class="hl opt">, </span>hashref<span class="hl opt">=&gt;</span><span class="hl kwb">$ref</span><span class="hl opt">);</span></li>
<li id="n_493" class="hl">        <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>project<span class="hl opt">} = ( </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>parts_id<span class="hl opt">} ) ? </span><span class="hl sng">&quot;job&quot;</span> <span class="hl opt">: </span><span class="hl sng">&quot;project&quot;</span><span class="hl opt">;</span></li>
<li id="n_494" class="hl">        <span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">} = </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdatea<span class="hl opt">};</span></li>
<li id="n_495" class="hl">        <span class="hl kwc">delete </span><span class="hl kwb">$ref</span><span class="hl opt">-&gt;{</span>transdatea<span class="hl opt">};</span></li>
<li id="n_496" class="hl">        <span class="hl kwc">push </span><span class="hl opt">&#64;{ </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transactions<span class="hl opt">} }, </span><span class="hl kwb">$ref</span><span class="hl opt">;</span></li>
<li id="n_497" class="hl">    <span class="hl opt">}</span></li>
<li id="n_498" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_499" class="hl"></li>
<li id="n_500" class="hl">    <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">commit</span><span class="hl opt">;</span></li>
<li id="n_501" class="hl"></li>
<li id="n_502" class="hl"><span class="hl opt">}</span></li>
<li id="n_503" class="hl"></li>
<li id="n_504" class="hl"><span class="hl kwa">sub </span>save <span class="hl opt">{</span></li>
<li id="n_505" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$self</span><span class="hl opt">, </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form </span><span class="hl opt">) = </span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_506" class="hl"></li>
<li id="n_507" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dbh </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>dbh<span class="hl opt">};</span></li>
<li id="n_508" class="hl"></li>
<li id="n_509" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$query</span><span class="hl opt">;</span></li>
<li id="n_510" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$sth</span><span class="hl opt">;</span></li>
<li id="n_511" class="hl"></li>
<li id="n_512" class="hl">    <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$project_id </span><span class="hl opt">) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>projectnumber<span class="hl opt">};</span></li>
<li id="n_513" class="hl"></li>
<li id="n_514" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} ) {</span></li>
<li id="n_515" class="hl"></li>
<li id="n_516" class="hl">        <span class="hl slc"># check if it was a job</span></li>
<li id="n_517" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_518" class="hl">            SELECT pr<span class="hl opt">.</span>parts_id<span class="hl opt">, </span>pr<span class="hl opt">.</span>production <span class="hl opt">- </span>pr<span class="hl opt">.</span>completed</li>
<li id="n_519" class="hl">              FROM project pr</li>
<li id="n_520" class="hl">              JOIN jcitems j ON <span class="hl opt">(</span>j<span class="hl opt">.</span>project_id <span class="hl opt">= </span>pr<span class="hl opt">.</span>id<span class="hl opt">)</span></li>
<li id="n_521" class="hl">             WHERE j<span class="hl opt">.</span>id <span class="hl opt">= ?|;</span></li>
<li id="n_522" class="hl">        <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_523" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} );</span></li>
<li id="n_524" class="hl">        <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$job_id</span><span class="hl opt">, </span><span class="hl kwb">$qty </span><span class="hl opt">) = </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array</span><span class="hl opt">();</span></li>
<li id="n_525" class="hl">        <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">finish</span><span class="hl opt">;</span></li>
<li id="n_526" class="hl">        <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$job_id </span><span class="hl opt">&amp;&amp; </span><span class="hl kwb">$qty </span><span class="hl opt">== </span><span class="hl num">0 </span><span class="hl opt">) {</span></li>
<li id="n_527" class="hl">            <span class="hl kwa">return </span><span class="hl opt">-</span><span class="hl num">1</span><span class="hl opt">;</span></li>
<li id="n_528" class="hl">        <span class="hl opt">}</span></li>
<li id="n_529" class="hl"></li>
<li id="n_530" class="hl">        <span class="hl slc"># check if new one belongs to a job</span></li>
<li id="n_531" class="hl">        <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$project_id</span><span class="hl opt">) {</span></li>
<li id="n_532" class="hl">            <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_533" class="hl">                SELECT pr<span class="hl opt">.</span>parts_id<span class="hl opt">, </span></li>
<li id="n_534" class="hl">                       pr<span class="hl opt">.</span>production <span class="hl opt">- </span>pr<span class="hl opt">.</span>completed</li>
<li id="n_535" class="hl">                  FROM project pr</li>
<li id="n_536" class="hl">                 WHERE pr<span class="hl opt">.</span>id <span class="hl opt">= ?|;</span></li>
<li id="n_537" class="hl">            <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_538" class="hl">            <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span><span class="hl kwb">$project_id</span><span class="hl opt">);</span></li>
<li id="n_539" class="hl">            <span class="hl kwc">my </span><span class="hl opt">( </span><span class="hl kwb">$job_id</span><span class="hl opt">, </span><span class="hl kwb">$qty </span><span class="hl opt">) = </span><span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">fetchrow_array</span><span class="hl opt">();</span></li>
<li id="n_540" class="hl"></li>
<li id="n_541" class="hl">            <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$job_id </span><span class="hl opt">&amp;&amp; </span><span class="hl kwb">$qty </span><span class="hl opt">== </span><span class="hl num">0 </span><span class="hl opt">) {</span></li>
<li id="n_542" class="hl">                <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">disconnect</span><span class="hl opt">;</span></li>
<li id="n_543" class="hl">                <span class="hl kwa">return </span><span class="hl opt">-</span><span class="hl num">2</span><span class="hl opt">;</span></li>
<li id="n_544" class="hl">            <span class="hl opt">}</span></li>
<li id="n_545" class="hl">        <span class="hl opt">}</span></li>
<li id="n_546" class="hl"></li>
<li id="n_547" class="hl">    <span class="hl opt">}</span></li>
<li id="n_548" class="hl">    <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_549" class="hl">        <span class="hl kwc">my </span><span class="hl kwb">$uid </span><span class="hl opt">= </span><span class="hl kwc">localtime</span><span class="hl opt">;</span></li>
<li id="n_550" class="hl">        <span class="hl kwb">$uid </span><span class="hl opt">.= </span><span class="hl sng">&quot;</span><span class="hl ipl">$$</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_551" class="hl"></li>
<li id="n_552" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>INSERT INTO jcitems <span class="hl opt">(</span>description<span class="hl opt">) </span>VALUES <span class="hl opt">(</span><span class="hl sng">&#39;</span><span class="hl ipl">$uid</span><span class="hl sng">&#39;</span><span class="hl opt">)|;</span></li>
<li id="n_553" class="hl">        <span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwa">do</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_554" class="hl"></li>
<li id="n_555" class="hl">        <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span>SELECT id FROM jcitems WHERE description <span class="hl opt">= </span><span class="hl sng">&#39;</span><span class="hl ipl">$uid</span><span class="hl sng">&#39;</span><span class="hl opt">|;</span></li>
<li id="n_556" class="hl">        <span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">} ) = </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">selectrow_array</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_557" class="hl">    <span class="hl opt">}</span></li>
<li id="n_558" class="hl"></li>
<li id="n_559" class="hl">    <span class="hl kwa">for </span><span class="hl opt">(</span><span class="hl sng">qw(inhour inmin insec outhour outmin outsec)</span><span class="hl opt">) {</span></li>
<li id="n_560" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} = </span><span class="hl kwc">substr</span><span class="hl opt">( </span><span class="hl sng">&quot;00</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{</span><span class="hl ipl">$_</span><span class="hl sng">}&quot;</span><span class="hl opt">, -</span><span class="hl num">2 </span><span class="hl opt">);</span></li>
<li id="n_561" class="hl">    <span class="hl opt">}</span></li>
<li id="n_562" class="hl">    <span class="hl kwa">for </span><span class="hl opt">(</span><span class="hl sng">qw(qty sellprice allocated)</span><span class="hl opt">) {</span></li>
<li id="n_563" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} = </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">parse_amount</span><span class="hl opt">( </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span><span class="hl kwb">$_</span><span class="hl opt">} );</span></li>
<li id="n_564" class="hl">    <span class="hl opt">}</span></li>
<li id="n_565" class="hl"></li>
<li id="n_566" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$checkedin  </span><span class="hl opt">= </span><span class="hl sng">&quot;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{inhour}</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{inmin}</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{insec}&quot;</span><span class="hl opt">;</span></li>
<li id="n_567" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$checkedout </span><span class="hl opt">= </span><span class="hl sng">&quot;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{outhour}</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{outmin}</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{outsec}&quot;</span><span class="hl opt">;</span></li>
<li id="n_568" class="hl"></li>
<li id="n_569" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$outdate </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">};</span></li>
<li id="n_570" class="hl">    <span class="hl kwa">if </span><span class="hl opt">( </span><span class="hl kwb">$checkedout </span><span class="hl opt">&lt; </span><span class="hl kwb">$checkedin </span><span class="hl opt">) {</span></li>
<li id="n_571" class="hl">        <span class="hl kwb">$outdate </span><span class="hl opt">= </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">add_date</span><span class="hl opt">( </span><span class="hl kwb">$myconfig</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>transdate<span class="hl opt">}, </span><span class="hl num">1</span><span class="hl opt">, </span><span class="hl sng">&#39;days&#39;</span> <span class="hl opt">);</span></li>
<li id="n_572" class="hl">    <span class="hl opt">}</span></li>
<li id="n_573" class="hl"></li>
<li id="n_574" class="hl">    <span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee_id<span class="hl opt">} ) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee<span class="hl opt">};</span></li>
<li id="n_575" class="hl">    <span class="hl kwa">unless </span><span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee_id<span class="hl opt">} ) {</span></li>
<li id="n_576" class="hl">        <span class="hl opt">( </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee<span class="hl opt">}, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee_id<span class="hl opt">} ) = </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">get_employee</span><span class="hl opt">(</span><span class="hl kwb">$dbh</span><span class="hl opt">);</span></li>
<li id="n_577" class="hl">    <span class="hl opt">}</span></li>
<li id="n_578" class="hl"></li>
<li id="n_579" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$parts_id</span><span class="hl opt">;</span></li>
<li id="n_580" class="hl">    <span class="hl opt">( </span><span class="hl kwb">$null</span><span class="hl opt">, </span><span class="hl kwb">$parts_id </span><span class="hl opt">) = </span><span class="hl kwc">split </span><span class="hl kwd">/--/</span><span class="hl opt">, </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>partnumber<span class="hl opt">};</span></li>
<li id="n_581" class="hl"></li>
<li id="n_582" class="hl">    <span class="hl kwb">$query </span><span class="hl opt">= </span>qq<span class="hl opt">|</span></li>
<li id="n_583" class="hl">        UPDATE jcitems </li>
<li id="n_584" class="hl">           SET project_id <span class="hl opt">= ?,</span></li>
<li id="n_585" class="hl">               parts_id <span class="hl opt">= ?,</span></li>
<li id="n_586" class="hl">               description <span class="hl opt">= ?,</span></li>
<li id="n_587" class="hl">               qty <span class="hl opt">= ?,</span></li>
<li id="n_588" class="hl">               allocated <span class="hl opt">= ?,</span></li>
<li id="n_589" class="hl">               sellprice <span class="hl opt">= ?,</span></li>
<li id="n_590" class="hl">               fxsellprice <span class="hl opt">= ?,</span></li>
<li id="n_591" class="hl">               serialnumber <span class="hl opt">= ?,</span></li>
<li id="n_592" class="hl">               checkedin <span class="hl opt">= ?::</span>timestamp<span class="hl opt">,</span></li>
<li id="n_593" class="hl">               checkedout <span class="hl opt">= ?::</span>timestamp<span class="hl opt">,</span></li>
<li id="n_594" class="hl">               employee_id <span class="hl opt">= ?,</span></li>
<li id="n_595" class="hl">               notes <span class="hl opt">= ?</span></li>
<li id="n_596" class="hl">         WHERE id <span class="hl opt">= ?|;</span></li>
<li id="n_597" class="hl">    <span class="hl kwb">$sth </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">prepare</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_598" class="hl">    <span class="hl kwb">$sth</span><span class="hl opt">-&gt;</span><span class="hl kwd">execute</span><span class="hl opt">(</span></li>
<li id="n_599" class="hl">        <span class="hl kwb">$project_id</span><span class="hl opt">,</span></li>
<li id="n_600" class="hl">        <span class="hl kwb">$parts_id</span><span class="hl opt">,</span></li>
<li id="n_601" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>description<span class="hl opt">},</span></li>
<li id="n_602" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>qty<span class="hl opt">},</span></li>
<li id="n_603" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>allocated<span class="hl opt">},</span></li>
<li id="n_604" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>sellprice<span class="hl opt">},</span></li>
<li id="n_605" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>sellprice<span class="hl opt">},</span></li>
<li id="n_606" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>serialnumber<span class="hl opt">},</span></li>
<li id="n_607" class="hl">        <span class="hl sng">&quot;</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{transdate} </span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{inhour}:</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{inmin}:&quot;</span> <span class="hl opt">. </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>insec<span class="hl opt">},</span></li>
<li id="n_608" class="hl">        <span class="hl sng">&quot;</span><span class="hl ipl">$outdate </span><span class="hl sng"></span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{outhour}:</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{outmin}:</span><span class="hl ipl">$form</span><span class="hl sng">-&gt;{outsec}&quot;</span><span class="hl opt">,</span></li>
<li id="n_609" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>employee_id<span class="hl opt">},</span></li>
<li id="n_610" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>notes<span class="hl opt">},</span></li>
<li id="n_611" class="hl">        <span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">}</span></li>
<li id="n_612" class="hl">    <span class="hl opt">) || </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">dberror</span><span class="hl opt">(</span><span class="hl kwb">$query</span><span class="hl opt">);</span></li>
<li id="n_613" class="hl"></li>
<li id="n_614" class="hl">    <span class="hl slc"># save printed, queued</span></li>
<li id="n_615" class="hl">    <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">save_status</span><span class="hl opt">(</span><span class="hl kwb">$dbh</span><span class="hl opt">);</span></li>
<li id="n_616" class="hl"></li>
<li id="n_617" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">%audittrail </span><span class="hl opt">= (</span></li>
<li id="n_618" class="hl">        tablename <span class="hl opt">=&gt; </span><span class="hl sng">&#39;jcitems&#39;</span><span class="hl opt">,</span></li>
<li id="n_619" class="hl">        reference <span class="hl opt">=&gt; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">},</span></li>
<li id="n_620" class="hl">        formname  <span class="hl opt">=&gt; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>type<span class="hl opt">},</span></li>
<li id="n_621" class="hl">        action    <span class="hl opt">=&gt; </span><span class="hl sng">&#39;saved&#39;</span><span class="hl opt">,</span></li>
<li id="n_622" class="hl">        id        <span class="hl opt">=&gt; </span><span class="hl kwb">$form</span><span class="hl opt">-&gt;{</span>id<span class="hl opt">}</span></li>
<li id="n_623" class="hl">    <span class="hl opt">);</span></li>
<li id="n_624" class="hl"></li>
<li id="n_625" class="hl">    <span class="hl kwb">$form</span><span class="hl opt">-&gt;</span><span class="hl kwd">audittrail</span><span class="hl opt">( </span><span class="hl kwb">$dbh</span><span class="hl opt">, </span><span class="hl sng">&quot;&quot;</span><span class="hl opt">, </span>\<span class="hl kwb">%audittrail </span><span class="hl opt">);</span></li>
<li id="n_626" class="hl"></li>
<li id="n_627" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$rc </span><span class="hl opt">= </span><span class="hl kwb">$dbh</span><span class="hl opt">-&gt;</span><span class="hl kwd">commit</span><span class="hl opt">;</span></li>
<li id="n_628" class="hl"></li>
<li id="n_629" class="hl">    <span class="hl kwb">$rc</span><span class="hl opt">;</span></li>
<li id="n_630" class="hl"></li>
<li id="n_631" class="hl"><span class="hl opt">}</span></li>
<li id="n_632" class="hl"></li>
<li id="n_633" class="hl"><span class="hl num">1</span><span class="hl opt">;</span></li>
<li id="n_634" class="hl"></li>
</ol></code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.46.0</a>) at 2025-06-29 10:48:18 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
