$tab) if(!$enabled_pages[$key]) unset($clientcompany_tabs[$key]); ?>
0 and clientcompanyid = ".clientcompanyid()." ) tblpreferredvendor using (staffid, accountstaffid, externaluserid, assignmentaliasclientstaffid) left join( --get a count of all of the open tasks, grouped by the ids and category select count(1) as cnt, staffid, accountstaffid, externaluserid, assignmentaliasclientstaffid, lineitemcategoryid from tblclienttask join tblclientpretask using (clientpretaskid,clientcompanypropertyassignmentid) join (select lineitemcategoryid, lineitemname from tbllineitemcategoryentry where clientcompanyid = ".clientcompanyid().")tbllineitemcategoryentry on (lower(lineitemname) = lower(clientpretaskname)) join tblclientcompanypropertyassignment using (clientcompanypropertyassignmentid) where 0=0 --and tblclientpretask.lineitemcategoryid = tblpreferredvendor.lineitemcategoryid and get_clienttask_statuskey(clienttaskduedate, clienttaskcompleteddate, clienttaskcompleteapproveddate, clienttaskrevokeddate, clienttaskholddate::date) in ('open', 'warning', 'pastdue') group by staffid, accountstaffid, externaluserid, assignmentaliasclientstaffid, lineitemcategoryid ) tblopencountsbycatid using (staffid, accountstaffid, externaluserid, assignmentaliasclientstaffid) "; //d(sql, $sql); $qry = db_query($sql); return $qry; } function get_specificlineitempricing($lineitemcategoryentryid, $zipregion, $clientcompanyclientid) { $retval = array(); $lineitemcategoryentryid = db_number($lineitemcategoryentryid); if (!$lineitemcategoryentryid) return $retval; $retval = db_query(" select lineitempricingregion, clientcompanyclientid, lineitempricingvendorprice, lineitempricingclientprice from tbllineitempricing where lineitemcategoryentryid = " . $lineitemcategoryentryid ); $retrow = null; foreach($retval as $row) { if($row[lineitempricingregion] == $zipregion && $row[clientcompanyclientid] == $clientcompanyclientid) {//Best possible match. $retrow = $row; break; } else if($row[lineitempricingregion] == $zipregion || $row[clientcompanyclientid] == $clientcompanyclientid) {//Next best match; keep looking. $retrow = $row; } else if($retrow === null) {//Least preferred match; only take if no other choice. $retrow = $row; } } return $retrow; } /** * @name format_alphanumsinglespace * @param &$val which is passed by reference, so function works on argument without the need to use return value; $val is modified with all non-alphanumeric characters stripped out, and each section of contiguous whitespace modified to a single space * @return None, so will not work if somebody does not realize that it is pass by reference. Need pass by reference so will work as a callback function for various php array functions, like array_walk. */ function format_alphanumsinglespace(&$val) { $val = preg_replace("/[^0-9a-zA-Z ]/", "", $val); $val = preg_replace('!\s+!', ' ', $val); $val = trim($val); }