/** * Given an id for an agent, get the collector number patterns for that agent, marked up as html for display. * * @param agentid, the id for the agent for which to find collector number patterns. * @return an html list of agent number patterns. */ public function getNumberPatternsForAgent($agentid) { global $clientRoot; $result = ""; $result .= "<li><h3>Collector Number Patterns</h3></li>"; $link = ""; if ($this->isAgentEditor()) { $link .= "<a id='addNumberPatternLink'>Add</a>\n"; } $result .= "<div id='addNumberPatternDiv'>{$link}</div>\n"; $result .= "<div id='addedNumberPatternDiv'></div>\n"; if ($this->isAgentEditor()) { $result .= "\n <script type='text/javascript'>\n function handlerAddName () {\n \$.ajax({\n type: 'GET',\n url: '{$clientRoot}/agents/rpc/handler.php',\n data: 'mode=create&table=AgentNumberPattern&agentid=" . $agentid . "',\n dataType : 'html',\n success: function(data){\n \$('#addedNumberPatternDiv').html(data);\n },\n error: function( xhr, status, errorThrown ) {\n \$('#statusDiv').html('Error. ' + errorThrown);\n console.log( 'Error: ' + errorThrown );\n console.log( 'Status: ' + status );\n console.dir( xhr );\n }\n });\n return false; \n };\n \$('#addNumberPatternLink').bind('click',handlerAddName);\n </script>\n "; } $numpat = new agentnumberpattern(); $numpats = $numpat->loadArrayByagentid($agentid); if (count($numpats) > 0) { $numpatView = new agentnumberpatternView(); $result .= "<ul>"; foreach ($numpats as $np) { $numpatView->setModel($np); $result .= '<li>' . $numpatView->getSummaryLine($this->isAgentEditor()) . '</li>'; } $result .= "</ul>"; //$result .= "<table>"; //$result .= $numpatView->getShortHeaderRow(); //foreach ($numpats as $np) { // $numpatView->setModel($np); // $result .= $numpatView->getShortTableRowView(); //} //$result .= "</table>"; } return $result; }
function editAgentNumberPattern($np) { $result = ""; $am = new AgentManager(); if ($am->isAgentEditor()) { if ($np == null) { $result = "Error: No agent number pattern found"; } else { $npview = new agentnumberpatternView(); $npview->setModel($np); $result = $npview->getEditFormView(); } } else { $result = "You aren't authorized to edit agent records."; } return $result; }