public function display() { $data['members'] = $this->member_model->get_memberlist(); $data['privileges'] = getPrivileges(); $template['content'] = $this->load->view('member/list', $data, TRUE); $this->load->view('template/page_template', $template); }
public function data($member_id) { $data['member'] = $this->member_model->get_member($member_id); $data['member'][0]->member_id = $member_id; $data['privileges'] = getPrivileges(); $data['memberId'] = $member_id; $data['member_id'] = $member_id; $data['accounts'] = $this->account_model->get_reading($member_id, Null, 'DESC'); $template['content'] = $this->load->view('account/info', $data, TRUE); $this->load->view('template/page_template', $template); }
public function data($member_id, $page = 0) { $data['member'] = $this->member_model->get_member($member_id); $limit = 12; $offset = $page; $total = $this->account_model->count_all_reading_results($member_id); $data['accounts'] = $this->account_model->get_reading($member_id, Null, Null, $limit, $offset); $data['meter_readings'] = $this->account_model->get_reading($member_id, Null, Null, Null, Null); $data['privileges'] = getPrivileges(); $config['base_url'] = '/account/data/' . $member_id; $config['total_rows'] = $total; $config['per_page'] = $limit; $config['num_links'] = 2; $config['uri_segment'] = 4; $this->pagination->initialize($config); $template['content'] = $this->load->view('account/info', $data, TRUE); $this->load->view('template/page_template', $template); }
private function get_master_list() { $members = $this->member_model->get_memberlist(); $privileges = getPrivileges(); foreach ($members as $member) { $ap_privileges = array("N/A"); if (isset($member->privilege)) { $ap_privileges = array(); foreach (explode(",", $member->privilege) as $privilege_id) { $ap_privileges[] = $privileges[$privilege_id]['name']; } } $members_data[$member->member_id] = array('first_name' => $member->first_name, 'last_name' => $member->last_name, 'zone' => $member->zone, 'account_number' => $member->account_number, 'serial_number' => $member->serial_number, 'purok' => $member->purok, 'address' => $member->address, 'nature' => $member->nature, 'privilige' => implode(" , ", $ap_privileges), 'status' => $member->status); } return $members_data; }
public function details($member_id) { $billing_data = $accounts_list = $paymentslist = array(); $prev_ob = $months_delayed = $amount = $i = $count_months = 0; $payment_status = ''; $member_data = $this->member_model->get_member($member_id); $data['member'] = $member_data; $accounts = $this->account_model->get_reading($member_id, Null, 'ASC'); $data['privileges'] = getPrivileges(); $initial_ob = get_object_vars(array_pop($member_data)); $initialize_object = new stdClass(); $initialize_object->previous_reading = 0; $initialize_object->current_reading = 0; $initialize_object->date = 0; $initialize_object->meter_reading_id = 0; $initialize_object->added = ''; $initialize_object->member_id = $member_id; $accounts_list[] = array(0 => $initialize_object); foreach ($accounts as $key => $account_read) { $accounts_list[$account_read->date][$account_read->meter_reading_id] = $account_read; } $data['payments'] = $this->payment_model->get_payments($member_id); $outsanding_balance = $initial_ob['initial_ob']; $listpayments = create_payment_matrix($data['payments']); $paymentslist = $listpayments['list']; $total_bal_diff = $listpayments['grand_total'] - $outsanding_balance; $paymentslist_ids = array_keys($paymentslist); if (!empty($accounts_list)) { ksort($accounts_list); $accounts_list_ids = array_keys($accounts_list); foreach ($accounts_list_ids as $count => $bill_period_timestamp) { $account = $accounts_list[$bill_period_timestamp]; $current_reading = $previous_reading = 0; $wmm = WMM; $paymentD = []; foreach ($account as $account_loop) { $current_reading = $current_reading + $account_loop->current_reading; $previous_reading = $previous_reading + $account_loop->previous_reading; } $consumed_cubic = $current_reading - $previous_reading; $amount = get_price($consumed_cubic); if ($bill_period_timestamp == 0 && $consumed_cubic == 0) { $wmm = $amount = 0; } $total_discount = $total_basicpayment = $total_regular_discount = 0; $total_adjustment = $total_penalty = $total_wmm = $total_payment = $total_charges = 0; $total_current = $amount + $wmm + $outsanding_balance; $prev_ob = $outsanding_balance; $outsanding_balance = $prev_ob + $amount + $wmm; $ob_display = number_format($prev_ob, 2, '.', ','); if ($prev_ob < 0) { $ob_display = 'Excess of ' . $prev_ob * -1; } $due_time = strtotime(date('Y-m-t', $bill_period_timestamp) . ' + 15 days'); $nextMonth = strtotime(date('Y-m-t', $bill_period_timestamp) . ' + 1 month'); $billinPeriod = date('M d', $bill_period_timestamp) . ' - ' . date('t', $bill_period_timestamp); $billPeriod = $billinPeriod . ', ' . date('Y', $bill_period_timestamp); $curr_amount = $amount + $wmm; $due_date = date('M j Y', $due_time); if ($bill_period_timestamp == 0) { $billinPeriod = "Line Connection"; $due_date = '--'; } $isPaymentData = false; $date_of_payment = ''; $billing_data[] = fillBillingData($billinPeriod, $bill_period_timestamp, $member_id, $due_date, $current_reading, $previous_reading, $consumed_cubic, $amount, $wmm, $total_current, $date_of_payment, $isPaymentData, $total_payment, $total_regular_discount, $total_discount, $total_basicpayment, $total_penalty, $total_charges, $total_adjustment, $ob_display, $outsanding_balance); $total_bal_diff = $total_bal_diff - $curr_amount; $aging_calc = $bill_period_timestamp == 0 ? $outsanding_balance : $outsanding_balance - $prev_ob; $current = $bill_period_timestamp; $next = $accounts_list_ids[$count + 1]; if ($bill_period_timestamp == 0) { $valid_payments = array_filter($paymentslist_ids, function ($value) use($current, $next) { return $value < $next; }); } else { if (!isset($next)) { $valid_payments = array_filter($paymentslist_ids, function ($value) use($current, $next) { return $value >= $current; }); } else { $valid_payments = array_filter($paymentslist_ids, function ($value) use($current, $next) { return $value >= $current && $value < $next; }); } } if (empty($valid_payments)) { continue; } foreach ($valid_payments as $valid_payments_id) { $paymentD[$valid_payments_id] = $paymentslist[$valid_payments_id]; } foreach ($paymentD as $datepaid => $paymentdata) { krsort($paymentdata); foreach ($paymentdata as $key => $paymententry) { $total_discount = !empty($paymententry['discount']) ? $paymententry['discount'] : 0; $total_basicpayment = !empty($paymententry['basic_charge']) ? $paymententry['basic_charge'] : 0; $total_regular_discount = !empty($paymententry['regular_discount']) ? $paymententry['regular_discount'] : 0; $total_adjustment = !empty($paymententry['adjustment']) ? $paymententry['adjustment'] : 0; $total_penalty = !empty($paymententry['penalty']) ? $paymententry['penalty'] : 0; $total_charges = !empty($paymententry['total_charges']) ? $paymententry['total_charges'] : 0; $total_wmm = !empty($paymententry['wmm']) ? $paymententry['wmm'] : 0; $total_payment = !empty($paymententry['total']) ? $paymententry['total'] : 0; $date_paid = !empty($paymententry['date_paid']) ? $paymententry['date_paid'] : 0; $total_current = $total_penalty + $total_charges + $outsanding_balance - ($total_discount + $total_adjustment + $total_regular_discount); $prev_ob = $outsanding_balance; $outsanding_balance = $prev_ob + $total_penalty + $total_charges - ($total_payment + $total_discount + $total_adjustment + $total_regular_discount); $ob_display = number_format($prev_ob, 2, '.', ','); if ($prev_ob > 0) { $months_delayed++; } if ($prev_ob < 0) { $ob_display = 'Excess of ' . $prev_ob * -1; } $date_of_payment = date('M j Y', $date_paid); $billinPeriod = date('F', $account_id); $isPaymentData = true; $billing_data[] = fillBillingData($billinPeriod, $account_id, $member_id, $due_date, $current_reading, $previous_reading, $consumed_cubic, $amount, $wmm, $total_current, $date_of_payment, $isPaymentData, $total_payment, $total_regular_discount, $total_discount, $total_basicpayment, $total_penalty, $total_charges, $total_adjustment, $ob_display, $outsanding_balance); $total_bal_diff = $total_bal_diff + $total_discount + $total_adjustment + $total_regular_discount - ($total_penalty + $total_charges); } } if ($total_bal_diff < 0 && strtotime("now") > strtotime($due_date) && $due_date != '--') { $count_months++; $aging[] = $aging_calc; } $pay_stat = strtotime("now") > strtotime($due_date) ? 'Late' : 'On Time'; if ($account_id == 0) { $billPeriod = '--'; } } } $data['count_months'] = $count_months; $data['pay_stat'] = $pay_stat; $data['due_date'] = $due_date; $data['billinPeriod'] = $billPeriod; $data['current_amount'] = $curr_amount; $data['total_ob'] = $outsanding_balance; $account_aging = array_fill(0, 4, 0); $sumball = $outsanding_balance; foreach (array_reverse($aging) as $key => $value) { if ($key > 2) { $account_aging[3] = $sumball; break; } else { $account_aging[$key] = $value; $sumball = $sumball - $value; } } $data['accounts'] = array_reverse($billing_data); $data['account_aging'] = $account_aging; $this->load->view('transaction/details', $data, FALSE); }
$httpsUrl = $host . $_SERVER['REQUEST_URI']; header('Location: ' . $httpsUrl); exit; } } $users = getUsers(); $currentUserInfo = getCurrentUserInfo($users); // Cache buster $git = __DIR__ . '/.git'; $cacheBuster = Directus\Util\Git::getCloneHash($git); $tableSchema = TableSchema::getAllSchemas($currentUserInfo['group']['id'], $cacheBuster); // $tabPrivileges = getTabPrivileges(($currentUserInfo['group']['id'])); $groupId = $currentUserInfo['group']['id']; $groups = getGroups(); $currentUserGroup = array(); if (isset($groups['rows']) && count($groups['rows'] > 0)) { foreach ($groups['rows'] as $group) { if ($group['id'] === $groupId) { $currentUserGroup = $group; break; } } } $statusMapping = array('active_num' => STATUS_ACTIVE_NUM, 'deleted_num' => STATUS_DELETED_NUM, 'status_name' => STATUS_COLUMN_NAME); $statusMapping['mapping'] = $config['statusMapping']; $data = array('cacheBuster' => $cacheBuster, 'nonces' => getNonces(), 'storage_adapters' => getStorageAdapters(), 'path' => DIRECTUS_PATH, 'page' => '#tables', 'tables' => parseTables($tableSchema), 'preferences' => parsePreferences($tableSchema), 'users' => $users, 'groups' => $groups, 'settings' => getSettings(), 'active_files' => getActiveFiles(), 'authenticatedUser' => $authenticatedUser, 'extensions' => getExtensions($currentUserGroup), 'privileges' => getPrivileges($groupId), 'ui' => getUI(), 'listViews' => getListViews(), 'messages' => getInbox(), 'bookmarks' => getBookmarks(), 'extendedUserColumns' => getExtendedUserColumns($tableSchema), 'statusMapping' => $statusMapping); $templateVars = array('cacheBuster' => $cacheBuster, 'data' => json_encode($data), 'path' => DIRECTUS_PATH, 'customFooterHTML' => getCusomFooterHTML(), 'cssFilePath' => getCSSFilePath(), 'cms_color' => '#89c33d'); if (isset($data['settings']) && isset($data['settings'][0]) && isset($data['settings'][0]['cms_color'])) { $templateVars['cms_color'] = $data['settings'][0]['cms_color']; } echo template(file_get_contents('main.html'), $templateVars);
function checkUserPrivileges($number) { global $db, $sms; $userId = getUser($number); $privileges = getPrivileges($userId); if ($privileges == 0) { sendSMS($number, _('Sorry, this command is only available for the privileged users.')); $sms->Respond(); exit; } }
// @NOTE: if the user doesn't have permission to view users // it should be log out // see: https://github.com/directus/directus/issues/1268 if (!$users) { AuthProvider::logout(); $_SESSION['error_message'] = 'Your user doesn\'t have permission to log in'; header('Location: ' . DIRECTUS_PATH . 'login.php'); exit; } $currentUserInfo = getCurrentUserInfo($users); // Cache buster $git = __DIR__ . '/.git'; $cacheBuster = Directus\Util\Git::getCloneHash($git); $tableSchema = TableSchema::getAllSchemas($currentUserInfo['group']['id'], $cacheBuster); // $tabPrivileges = getTabPrivileges(($currentUserInfo['group']['id'])); $groupId = $currentUserInfo['group']['id']; $groups = getGroups(); $currentUserGroup = []; if (isset($groups['rows']) && count($groups['rows'] > 0)) { foreach ($groups['rows'] as $group) { if ($group['id'] === $groupId) { $currentUserGroup = $group; break; } } } $statusMapping = ['active_num' => STATUS_ACTIVE_NUM, 'deleted_num' => STATUS_DELETED_NUM, 'status_name' => STATUS_COLUMN_NAME]; $statusMapping['mapping'] = $config['statusMapping']; $data = ['cacheBuster' => $cacheBuster, 'nonces' => getNonces(), 'storage_adapters' => getStorageAdapters(), 'path' => DIRECTUS_PATH, 'page' => '#tables', 'tables' => parseTables($tableSchema), 'preferences' => parsePreferences($tableSchema), 'users' => $users, 'groups' => $groups, 'settings' => getSettings(), 'active_files' => getActiveFiles(), 'authenticatedUser' => $authenticatedUser, 'extensions' => getExtensions($currentUserGroup), 'privileges' => getPrivileges($groupId), 'ui' => getUI(), 'locale' => get_user_locale(), 'localesAvailable' => parseLocalesAvailable(get_locales_available()), 'phrases' => get_phrases(get_user_locale()), 'timezone' => get_user_timezone(), 'timezones' => get_timezone_list(), 'listViews' => getListViews(), 'messages' => getInbox(), 'user_notifications' => getLoginNotification(), 'bookmarks' => getBookmarks(), 'extendedUserColumns' => getExtendedUserColumns($tableSchema), 'statusMapping' => $statusMapping]; $templateVars = ['cacheBuster' => $cacheBuster, 'data' => json_encode($data), 'path' => DIRECTUS_PATH, 'locale' => get_user_locale(), 'dir' => 'ltr', 'customFooterHTML' => getCusomFooterHTML(), 'cssFilePath' => getCSSFilePath()]; echo template(file_get_contents('main.html'), $templateVars);
{ $flag = false; for ($i = 0; $i < count($resourcePrivileges); ++$i) { if ($resource == $resourcePrivileges[$i]['resource_id'] && $privilege == $resourcePrivileges[$i]['privilege_id']) { $flag = true; break; } else { $flag = false; } } return $flag; } if (isset($_SESSION['pk_admin'])) { $roles = getRoles($connection); $resources = getResources($connection); $privileges = getPrivileges($connection); if (isset($_POST['role'])) { $roleId = getId('role', $_POST['role'], 'roles'); $resourcePrivileges = getResourcePrivileges($connection, $roleId); } else { $resourcePrivileges = getResourcePrivileges($connection, 1); } // draw a table for the page $content = '<thead><tr><th></th>'; // draw table header (row 1) foreach ($privileges as $key => $value) { $content = $content . '<th>' . $value['privilege'] . '</th>'; } $content = $content . '</tr></thead>'; // draw table content foreach ($resources as $key => $resourceValue) {
function privileges($mysql_link, $id, $priv_adm) { $priv = getPrivileges($mysql_link, $id); if (!$priv) { $priv = array(); } $arr = array_intersect($priv_adm, $priv); if ($arr === $priv_adm) { return TRUE; } return FALSE; }