[Added customer and reseller management functions Adrian Georgescu **20070906123816] hunk ./provisioning_logic.phtml 33 + ), + 'customers' => array('recordsClass' => 'Customers', + 'soapClass' => 'WebService_NGNPro_CustomerPort' hunk ./provisioning_logic.phtml 82 + $this->enableResellers= $this->soapEngines[$this->soapEngineId]['enableResellers']; + hunk ./provisioning_logic.phtml 158 - function showEngineSelection() { - $selected_soapEngine[$this->service]='selected'; - - printf (""); - } - hunk ./provisioning_logic.phtml 255 + var $resellers = array(); + var $customers = array(); hunk ./provisioning_logic.phtml 263 - $this->next = $_REQUEST['next']; hunk ./provisioning_logic.phtml 264 - $this->reseller=$this->SOAPEngine->reseller; + $this->next = $_REQUEST['next']; + $this->adminonly = trim($_REQUEST['adminonly']); hunk ./provisioning_logic.phtml 267 - $this->url = $this->SOAPEngine->url; + $this->reseller = $this->SOAPEngine->reseller; + $this->url = $this->SOAPEngine->url; hunk ./provisioning_logic.phtml 276 + + $this->filters['customer']=trim($_REQUEST['filter_customer']); + $this->filters['reseller']=trim($_REQUEST['filter_reseller']); + + if ($this->filters['customer']) { + $this->url .= sprintf('&filter_customer=%s',$this->filters['customer']); + } + + if ($this->filters['reseller']) { + $this->url .= sprintf('&filter_reseller=%s',$this->filters['reseller']); + } + + $this->getResellers(); + $this->getCustomers(); + hunk ./provisioning_logic.phtml 293 + function showEngineSelection() { + $selected_soapEngine[$this->SOAPEngine->service]='selected'; + + printf (""); + if ($this->adminonly) { + $this->showResellerForm(); + } else { + $this->showCustomerForm(); + } + } + + hunk ./provisioning_logic.phtml 334 - hunk ./provisioning_logic.phtml 344 - print "Begin "; + printf ("Begin",$url_begin); hunk ./provisioning_logic.phtml 346 - print "Previous"; + printf ("Previous",$url_prev); hunk ./provisioning_logic.phtml 357 - print "Next"; + printf ("Next",$url_next); hunk ./provisioning_logic.phtml 380 - $this->SOAPEngine->showEngineSelection(); + $this->showEngineSelection(); hunk ./provisioning_logic.phtml 530 + + function getCustomers() { + if (!$this->SOAPEngine->enableResellers) return; + } + + function getResellers() { + if (!$this->SOAPEngine->enableResellers) return; + if (!$this->adminonly) { + return; + } + + //print "getResellers()"; + } + + function showCustomerForm() { + print " Customer:"; + if (count($this->customers) && count($this->customers) < 200) { + $select_customer[$this->filters['customer']]='selected'; + print ""; + } else { + printf ("",$this->filters['customer']); + } + } + + function showResellerForm() { + print " Reseller:"; + if (count($this->resellers) && count($this->resellers) < 200) { + $select_reseller[$this->filters['reseller']]='selected'; + print ""; + } else { + printf ("",$this->filters['reseller']); + } + } hunk ./provisioning_logic.phtml 663 - hunk ./provisioning_logic.phtml 676 - hunk ./provisioning_logic.phtml 2525 - $this->filters = array('username' => trim($_REQUEST['username_filter']), - 'domain' => trim($_REQUEST['domain_filter']), - 'fullname' => trim($_REQUEST['fullname_filter']) - ); + $this->filters = array('username' => trim($_REQUEST['username_filter']), + 'domain' => trim($_REQUEST['domain_filter']), + 'fullname' => trim($_REQUEST['fullname_filter']) + ); hunk ./provisioning_logic.phtml 2753 + hunk ./provisioning_logic.phtml 2757 - %s (%s) + %s (%s.%s) hunk ./provisioning_logic.phtml 2773 + $this->customer, hunk ./provisioning_logic.phtml 3152 - %s@%s + %s@%s (%s.%s) hunk ./provisioning_logic.phtml 3162 + $alias->customer, + $alias->reseller, hunk ./provisioning_logic.phtml 3726 + } + } +} + +class Customers extends Records { + + var $maxrowsperpage= 200; + + function Customers(&$SOAPEngine) { + $this->filters = array( + 'id' => trim($_REQUEST['id_filter']) + ); + + $this->Records(&$SOAPEngine); + } + + function listRecords() { + + $this->showSeachForm(); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclient->getCustomers(); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + $this->rows = count($result); + + print " + + +
$this->rows records found
+

+ + + + + + + + + + + + "; + + if (!$this->next) $this->next=0; + + if ($this->rows > $this->maxrowsperpage) { + $maxrows = $this->maxrowsperpage + $this->next; + if ($maxrows > $this->rows) $maxrows = $this->maxrowsperpage; + } else { + $maxrows=$this->rows; + } + + $i=0; + + if ($this->rows) { + while ($i < $maxrows) { + + $customer = $result[$i]; + $index = $this->next+$i+1; + + $rr=floor($index/2); + $mod=$index-$rr*2; + + if ($mod ==0) { + $bgcolor="lightgrey"; + } else { + $bgcolor="white"; + } + + $_url = $this->url.sprintf("&service=%s&action=Delete", + urlencode($this->SOAPEngine->service) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['domain_filter'] == $domain) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + + printf(" + + + + + + + + + + + ", + $bgcolor, + $index, + $customer->id, + $customer->reseller, + $customer->name, + $customer->organization, + $customer->email, + $customer->tel, + $customer->web, + $_url, + $actionText + ); + + $i++; + } + } + + print "
Id + CustomerIdResellerIdNameOrganizationE-mailTelephoneWebAction
%s%s%s%s%s%s%s%s%s
"; + + $this->showPagination($maxrows); + + return true; + } + } + + function showSeachFormCustom() { + + printf (" Customer Id: ",$this->filters['id']); + + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['id']) || !strlen($this->filters['id'])) { + print "

Error: missing customer id. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['id']); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Customer id %s has been deleted. ",$this->filters['id']); + unset($this->filters); + return 1;