function init($data) { if ($this->user['type'] != 1) { return parse_bill_xml($user, 0, 'new'); } $accounts_xml = file_get_contents($this->user['folder'] . "/templates/accounts.xml"); $xml = new SimpleXMLElement($accounts_xml); $accounts_result = query("SELECT *\n\t\t\t\t\t\t\t\t\tFROM `" . $this->user['database'] . "`.accounts\n\t\t\t\t\t\t\t\t\tWHERE group_id = " . $this->user['group'] . " AND active=1\n\t\t\t\t\t\t\t\t\tORDER BY id\n\t\t\t\t\t\t\t\t\tLIMIT " . $data * $xml->entries_per_page . "," . $xml->entries_per_page); $num_result = query("SELECT id FROM `" . $this->user['database'] . "`.accounts WHERE group_id='" . $this->user['group'] . "'"); $num = num_rows($num_result); $pageCount = ceil($num / $xml->entries_per_page); $result_count = num_rows($accounts_result); for ($i = 0; $i < $xml->entries_per_page; $i++) { if ($i < $result_count) { $resultSet[] = fetch($accounts_result); } } $login_xml = file_get_contents($this->user['folder'] . "/templates/login.xml"); $inputs_xml = new SimpleXMLElement($login_xml); $hiddenPopup .= "<div id='shipon_account_popup' class='shipon_popup' title='" . text('new_account') . "'>"; foreach ($xml->popup->children() as $block) { $hiddenPopup .= "<div class='shipon_fieldblock' style='width: " . $block['width'] . "'>"; if (count($block->label)) { $block->label = text($block->label); } $elements = $block->children(); foreach ($elements as $element) { $hiddenPopup .= $element->asXML(); } $hiddenPopup .= "</div>"; } foreach ($inputs_xml->input as $input) { $hiddenPopup .= "<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<label style='float: left; text-align: left; width: 75px;'>" . $input['text'] . ":</label>\n\t\t\t\t\t\t\t<input type='" . $input['type'] . "' id='" . $input['name'] . "_new' name='" . $input['name'] . "_mew' class='shipon_input'></input>\n\t\t\t\t\t\t</div>"; } $hiddenPopup .= "\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<a class='dialog_action shipon_button' onclick='shipon_process_account(this)'> " . text('create') . " </a>\n\t\t\t\t\t\t\t<span id='shipon_account_output'></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $hiddenPopup .= "\t<div id='shipon_edit_account_popup' class='shipon_popup' title='" . text('edit_account') . "'>"; foreach ($xml->popup->children() as $block) { $hiddenPopup .= "<div class='shipon_fieldblock' style='width: " . $block['width'] . "'>"; if (count($block->label)) { $block->label = text((string) $block->label) . ":"; } $elements = $block->children(); foreach ($elements as $element) { $element['name'] .= "_edit"; $element['id'] .= "_edit"; $hiddenPopup .= $element->asXML(); } $hiddenPopup .= "</div>"; } foreach ($inputs_xml->input as $input) { $hiddenPopup .= "<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<label style='float: left; text-align: left; width: 75px;'>" . $input['text'] . ":</label>\n\t\t\t\t\t\t\t<input type='" . $input['type'] . "' id='" . $input['name'] . "_edit' name='" . $input['name'] . "_edit' class='shipon_input'></input>\n\t\t\t\t\t\t</div>"; } $hiddenPopup .= "\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<a class='dialog_action shipon_button' onclick='shipon_edit_account(this)'> " . text('save') . " </a>\n\t\t\t\t\t\t\t<span id='shipon_account_output'></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $close = 'jQuery("#shipon_account_delete_popup").dialog("close");'; $hiddenPopup .= "\t<div id='shipon_account_delete_popup' class='shipon_popup' title='" . text('delete_account') . "'>\n\t\t\t\t\t\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t" . text('account_delete_message') . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<a class='shipon_button' id='shipon_delete_yes' onclick='shipon_delete_account()'> " . text('yes') . " </a>\n\t\t\t\t\t\t\t<a class='shipon_button' id='shipon_delete_no' onclick='" . $close . "'> " . text('no') . " </a>\n\t\t\t\t\t\t\t<input type='hidden' id='shipon_delete_address_id'></input>\n\t\t\t\t\t\t\t<span id='shipon_delete_output'></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $pagination = $this->get_paged_footer("#manage_accounts", $xml->entries_per_page, $pageCount, $xml->page_numbers); $this->smarty->assign('hiddenPopup', $hiddenPopup); $this->smarty->assign('accounts', $resultSet); $this->smarty->assign('pagination', $pagination); $this->html['shipon_content'] = $this->smarty->fetch('accounts/accounts.tpl'); }
function parse_accounts_xml($user) { if ($user['type'] != 1) { return parse_bill_xml($user, 0, 'new'); } $accounts_xml = file_get_contents($user['folder'] . "/templates/accounts.xml"); $xml = new SimpleXMLElement($accounts_xml); $accounts_result = query(" SELECT *\n\t\t\t\t\t\t\t\tFROM `" . $user['database'] . "`.accounts\n\t\t\t\t\t\t\t\tWHERE group_id = " . $user['group'] . "\n\t\t\t\t\t\t\t\tORDER BY id\n\t\t\t\t\t\t\t\tLIMIT " . $_REQUEST['data'] * $xml->entries_per_page . "," . $xml->entries_per_page); $num_result = query("SELECT id FROM `" . $user['database'] . "`.accounts WHERE group_id='" . $user['group'] . "'"); $num = num_rows($num_result); $pageCount = ceil($num / $xml->entries_per_page); $result_count = num_rows($accounts_result); $accounts = get_field_header('100%', 'manage_accounts', "<a class='shipon_button shipon_titlebutton' onclick='new_account()'> New </a>"); $accounts .= "<table id='shipon_accounts'>"; $accounts .= "<tr>\n\t\t\t\t\t<th width='" . $xml->content->colomn[0]['width'] . "'>" . text($xml->content->colomn[0]) . "</th>\n\t\t\t\t\t<th width='" . $xml->content->colomn[1]['width'] . "'>" . text($xml->content->colomn[1]) . "</th>\n\t\t\t\t\t<th width='" . $xml->content->colomn[2]['width'] . "'>" . text($xml->content->colomn[2]) . "</th>\n\t\t\t\t\t<th width='" . $xml->content->colomn[3]['width'] . "'>" . text($xml->content->colomn[3]) . "</th>\n\t\t\t\t</tr>"; for ($i = 0; $i < $xml->entries_per_page; $i++) { if ($i < $result_count) { $account = fetch($accounts_result); $accounts .= "<tr>\n\t\t\t\t\t\t\t<td>" . $account['id'] . "</td>\n\t\t\t\t\t\t\t<td>" . $account['username'] . "</td>\n\t\t\t\t\t\t\t<td>" . $account['name'] . "</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<a class='shipon_button shipon_accounts_button' '> " . text('edit') . " </a>"; if ($account['type'] != 1) { $accounts .= "<a class='shipon_button shipon_accounts_button' onclick='delete_account(this)'> " . text('delete') . " </a>"; } $accounts .= "\t</td>\n\t\t\t\t\t\t</tr>"; } else { $accounts .= "<tr><td></td><td></td><td></td><td></td></tr>"; } } $accounts .= "</table>"; $login_xml = file_get_contents($user['folder'] . "/templates/login.xml"); $xml = new SimpleXMLElement($login_xml); $accounts .= "\t<div id='shipon_account_popup' class='shipon_popup' title='" . text('new_account') . "'>\n\t\t\t\t\t\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<label class='shipon_label'>" . text('address_name') . "</label>\n\t\t\t\t\t\t\t<input type='text' id='shipon_account_name' name='shipon_account_name' class='shipon_input'></input>\n\t\t\t\t\t\t</div>"; foreach ($xml->input as $input) { $accounts .= "\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<label class='shipon_label'>" . $input['text'] . "</label>\n\t\t\t\t\t\t\t<input type='" . $input['type'] . "' id='" . $input['name'] . "' name='" . $input['name'] . "' class='shipon_input'></input>\n\t\t\t\t\t\t</div>"; } $accounts .= "\t\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<a class='dialog_action shipon_button' onclick='shipon_process_account(this)'> " . text('create') . " </a>\n\t\t\t\t\t\t\t<span id='shipon_account_output'></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $close = 'jQuery("#shipon_account_delete_popup").dialog("close");'; $accounts .= "\t<div id='shipon_account_delete_popup' class='shipon_popup' title='" . text('new_account') . "'>\n\t\t\t\t\t\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t" . text('account_delete_message') . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class='shipon_fieldblock' style='width: 100%'>\n\t\t\t\t\t\t\t<a class='shipon_button' onclick='shipon_delete_account(this)'> " . text('yes') . " </a>\n\t\t\t\t\t\t\t<a class='shipon_button' onclick='" . $close . "'> " . text('no') . " </a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; $accounts .= get_paged_footer("#address_book", $xml->entries_per_page, $pageCount, $xml->page_numbers); return $accounts; }