@@ -22,133 +22,133 @@ |
||
| 22 | 22 | ############################################################################### |
| 23 | 23 | |
| 24 | 24 | class Astpp_common extends CI_Model { |
| 25 | - // ------------------------------------------------------------------------ |
|
| 26 | - /** |
|
| 27 | - * initialises the class inheriting the methods of the class Model |
|
| 28 | - * |
|
| 29 | - * @return Usermodel |
|
| 30 | - */ |
|
| 31 | - function Astpp_common() { |
|
| 32 | - parent::__construct(); |
|
| 33 | - } |
|
| 34 | - /** |
|
| 35 | - * -------Here we write code for model astpp_common_model functions list_applyable_charges------ |
|
| 36 | - * Purpose: build array for applyable charge dropdown list. |
|
| 37 | - * @param |
|
| 38 | - * @return return array of applyable chargelist. |
|
| 39 | - */ |
|
| 40 | - function list_applyable_charges($accountid = '') { |
|
| 41 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
| 42 | - $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 25 | + // ------------------------------------------------------------------------ |
|
| 26 | + /** |
|
| 27 | + * initialises the class inheriting the methods of the class Model |
|
| 28 | + * |
|
| 29 | + * @return Usermodel |
|
| 30 | + */ |
|
| 31 | + function Astpp_common() { |
|
| 32 | + parent::__construct(); |
|
| 33 | + } |
|
| 34 | + /** |
|
| 35 | + * -------Here we write code for model astpp_common_model functions list_applyable_charges------ |
|
| 36 | + * Purpose: build array for applyable charge dropdown list. |
|
| 37 | + * @param |
|
| 38 | + * @return return array of applyable chargelist. |
|
| 39 | + */ |
|
| 40 | + function list_applyable_charges($accountid = '') { |
|
| 41 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
| 42 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
| 43 | 43 | $q = " SELECT * FROM `charges` where reseller_id =$reseller_id and id NOT IN(select charge_id from charge_to_account where accountid =$accountid) AND pricelist_id = '0'"; |
| 44 | - $item_arr = array(); |
|
| 45 | - $query = $this->db->query($q); |
|
| 46 | - if ($query->num_rows() > 0) { |
|
| 47 | - foreach ($query->result_array() as $row) { |
|
| 48 | - if ($row['charge'] > 0) { |
|
| 49 | - $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
|
| 50 | - } |
|
| 51 | - $item_arr[$row['id']] = $row['description'].' - '.$row['charge']; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - return $item_arr; |
|
| 55 | - } |
|
| 56 | - function quote($inp) { |
|
| 57 | - return "'".$this->db->escape_str($inp)."'"; |
|
| 58 | - } |
|
| 44 | + $item_arr = array(); |
|
| 45 | + $query = $this->db->query($q); |
|
| 46 | + if ($query->num_rows() > 0) { |
|
| 47 | + foreach ($query->result_array() as $row) { |
|
| 48 | + if ($row['charge'] > 0) { |
|
| 49 | + $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
|
| 50 | + } |
|
| 51 | + $item_arr[$row['id']] = $row['description'].' - '.$row['charge']; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + return $item_arr; |
|
| 55 | + } |
|
| 56 | + function quote($inp) { |
|
| 57 | + return "'".$this->db->escape_str($inp)."'"; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @param string $q |
|
| 62 | - * @param string $colname |
|
| 63 | - */ |
|
| 64 | - function db_get_item($q, $colname) { |
|
| 65 | - $item_arr = array(); |
|
| 66 | - $query = $this->db->query($q); |
|
| 67 | - if ($query->num_rows() > 0) { |
|
| 68 | - $row = $query->row_array(); |
|
| 69 | - return $row[$colname]; |
|
| 70 | - } |
|
| 71 | - return ''; |
|
| 72 | - } |
|
| 73 | - // Return the balance for a specific ASTPP account. |
|
| 74 | - function accountbalance($account) { |
|
| 75 | - $debit = 0; |
|
| 76 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
| 77 | - $query = $this->db->query($q); |
|
| 78 | - if ($query->num_rows() > 0) { |
|
| 79 | - $row = $query->row_array(); |
|
| 80 | - $debit = $row['val1']; |
|
| 81 | - } |
|
| 82 | - $credit = 0; |
|
| 83 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= ".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
| 84 | - $query = $this->db->query($q); |
|
| 85 | - if ($query->num_rows() > 0) { |
|
| 86 | - $row = $query->row_array(); |
|
| 87 | - $credit = $row['val1']; |
|
| 88 | - } |
|
| 89 | - $posted_balance = 0; |
|
| 90 | - $q = "SELECT * FROM accounts WHERE id = ".$this->quote($account); |
|
| 91 | - $query = $this->db->query($q); |
|
| 92 | - if ($query->num_rows() > 0) { |
|
| 93 | - $row = $query->row_array(); |
|
| 94 | - $posted_balance = $row['balance']; |
|
| 95 | - } |
|
| 96 | - $balance = ($debit - $credit + $posted_balance); |
|
| 97 | - return $balance; |
|
| 98 | - } |
|
| 99 | - function accounts_total_balance($reseller) { |
|
| 100 | - $debit = 0; |
|
| 101 | - $credit = 0; |
|
| 102 | - if ($reseller == "") { |
|
| 103 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 104 | - $debit = $this->db_get_item($q, 'val1'); |
|
| 60 | + /** |
|
| 61 | + * @param string $q |
|
| 62 | + * @param string $colname |
|
| 63 | + */ |
|
| 64 | + function db_get_item($q, $colname) { |
|
| 65 | + $item_arr = array(); |
|
| 66 | + $query = $this->db->query($q); |
|
| 67 | + if ($query->num_rows() > 0) { |
|
| 68 | + $row = $query->row_array(); |
|
| 69 | + return $row[$colname]; |
|
| 70 | + } |
|
| 71 | + return ''; |
|
| 72 | + } |
|
| 73 | + // Return the balance for a specific ASTPP account. |
|
| 74 | + function accountbalance($account) { |
|
| 75 | + $debit = 0; |
|
| 76 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
| 77 | + $query = $this->db->query($q); |
|
| 78 | + if ($query->num_rows() > 0) { |
|
| 79 | + $row = $query->row_array(); |
|
| 80 | + $debit = $row['val1']; |
|
| 81 | + } |
|
| 82 | + $credit = 0; |
|
| 83 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= ".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
| 84 | + $query = $this->db->query($q); |
|
| 85 | + if ($query->num_rows() > 0) { |
|
| 86 | + $row = $query->row_array(); |
|
| 87 | + $credit = $row['val1']; |
|
| 88 | + } |
|
| 89 | + $posted_balance = 0; |
|
| 90 | + $q = "SELECT * FROM accounts WHERE id = ".$this->quote($account); |
|
| 91 | + $query = $this->db->query($q); |
|
| 92 | + if ($query->num_rows() > 0) { |
|
| 93 | + $row = $query->row_array(); |
|
| 94 | + $posted_balance = $row['balance']; |
|
| 95 | + } |
|
| 96 | + $balance = ($debit - $credit + $posted_balance); |
|
| 97 | + return $balance; |
|
| 98 | + } |
|
| 99 | + function accounts_total_balance($reseller) { |
|
| 100 | + $debit = 0; |
|
| 101 | + $credit = 0; |
|
| 102 | + if ($reseller == "") { |
|
| 103 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 104 | + $debit = $this->db_get_item($q, 'val1'); |
|
| 105 | 105 | |
| 106 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 107 | - $credit = $this->db_get_item($q, 'val1'); |
|
| 106 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
| 107 | + $credit = $this->db_get_item($q, 'val1'); |
|
| 108 | 108 | |
| 109 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
|
| 110 | - } else { |
|
| 111 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ".$this->quote($reseller); |
|
| 112 | - } |
|
| 113 | - $posted_balance = $this->db_get_item($tmp, "val1"); |
|
| 109 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
|
| 110 | + } else { |
|
| 111 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ".$this->quote($reseller); |
|
| 112 | + } |
|
| 113 | + $posted_balance = $this->db_get_item($tmp, "val1"); |
|
| 114 | 114 | |
| 115 | - $balance = ($debit - $credit + $posted_balance); |
|
| 116 | - return $balance; |
|
| 117 | - } |
|
| 118 | - function count_dids($test) { |
|
| 119 | - $tmp = "SELECT COUNT(*) as val1 FROM dids ".$test; |
|
| 120 | - return $this->db_get_item($tmp, 'val1'); |
|
| 121 | - } |
|
| 115 | + $balance = ($debit - $credit + $posted_balance); |
|
| 116 | + return $balance; |
|
| 117 | + } |
|
| 118 | + function count_dids($test) { |
|
| 119 | + $tmp = "SELECT COUNT(*) as val1 FROM dids ".$test; |
|
| 120 | + return $this->db_get_item($tmp, 'val1'); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - function count_callingcards($where, $field = 'COUNT(*)') { |
|
| 124 | - $tmp = "SELECT $field as val FROM callingcards ".$where; |
|
| 125 | - return $this->db_get_item($tmp, 'val'); |
|
| 126 | - } |
|
| 123 | + function count_callingcards($where, $field = 'COUNT(*)') { |
|
| 124 | + $tmp = "SELECT $field as val FROM callingcards ".$where; |
|
| 125 | + return $this->db_get_item($tmp, 'val'); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - function count_accounts($test) { |
|
| 129 | - $tmp = "SELECT COUNT(*) as val1 FROM accounts ".$test; |
|
| 130 | - return $this->db_get_item($tmp, 'val1'); |
|
| 131 | - } |
|
| 128 | + function count_accounts($test) { |
|
| 129 | + $tmp = "SELECT COUNT(*) as val1 FROM accounts ".$test; |
|
| 130 | + return $this->db_get_item($tmp, 'val1'); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - function count_rategroup($test) { |
|
| 133 | + function count_rategroup($test) { |
|
| 134 | 134 | $tmp = "SELECT COUNT(*) as val1 FROM pricelists ".$test; |
| 135 | - return $this->db_get_item($tmp, 'val1'); |
|
| 136 | - } |
|
| 135 | + return $this->db_get_item($tmp, 'val1'); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - function count_termination($test = '') { |
|
| 138 | + function count_termination($test = '') { |
|
| 139 | 139 | $tmp = "SELECT COUNT(*) as val1 FROM outbound_routes ".$test; |
| 140 | - return $this->db_get_item($tmp, 'val1'); |
|
| 141 | - } |
|
| 140 | + return $this->db_get_item($tmp, 'val1'); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - function count_trunk($test = '') { |
|
| 143 | + function count_trunk($test = '') { |
|
| 144 | 144 | $tmp = "SELECT COUNT(*) as val1 FROM trunks ".$test; |
| 145 | - return $this->db_get_item($tmp, 'val1'); |
|
| 146 | - } |
|
| 145 | + return $this->db_get_item($tmp, 'val1'); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - function count_origination($test = '') { |
|
| 148 | + function count_origination($test = '') { |
|
| 149 | 149 | $tmp = "SELECT COUNT(*) as val1 FROM routes ".$test; |
| 150 | - return $this->db_get_item($tmp, 'val1'); |
|
| 151 | - } |
|
| 150 | + return $this->db_get_item($tmp, 'val1'); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | } |
| 154 | 154 | ?> |
@@ -51,10 +51,11 @@ discard block |
||
| 51 | 51 | $this->db->where("id", $id); |
| 52 | 52 | $query = $this->db->get("system"); |
| 53 | 53 | |
| 54 | - if ($query->num_rows() > 0) |
|
| 55 | - return $query->row_array(); |
|
| 56 | - else |
|
| 57 | - return false; |
|
| 54 | + if ($query->num_rows() > 0) { |
|
| 55 | + return $query->row_array(); |
|
| 56 | + } else { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | function remove_config($data) { |
@@ -89,10 +90,11 @@ discard block |
||
| 89 | 90 | $this->db->where("taxes_id", $id); |
| 90 | 91 | $query = $this->db->get("taxes"); |
| 91 | 92 | |
| 92 | - if ($query->num_rows() > 0) |
|
| 93 | - return $query->row_array(); |
|
| 94 | - else |
|
| 95 | - return false; |
|
| 93 | + if ($query->num_rows() > 0) { |
|
| 94 | + return $query->row_array(); |
|
| 95 | + } else { |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 96 | 98 | } |
| 97 | 99 | |
| 98 | 100 | function remove_tax($data) { |
@@ -373,10 +375,11 @@ discard block |
||
| 373 | 375 | function get_template_by_id_all($id) { |
| 374 | 376 | $this->db->where('id', $id); |
| 375 | 377 | $query = $this->db->get('templates'); |
| 376 | - if ($query->num_rows() > 0) |
|
| 377 | - return $query->row_array(); |
|
| 378 | - else |
|
| 379 | - return false; |
|
| 378 | + if ($query->num_rows() > 0) { |
|
| 379 | + return $query->row_array(); |
|
| 380 | + } else { |
|
| 381 | + return false; |
|
| 382 | + } |
|
| 380 | 383 | } |
| 381 | 384 | |
| 382 | 385 | function edit_template($edit_id, $data) { |
@@ -48,10 +48,11 @@ discard block |
||
| 48 | 48 | function save($tableName, $arr, $val = 'false') { |
| 49 | 49 | $str = $this->db->insert_string($tableName, $arr); |
| 50 | 50 | $rs = $this->db->query($str); |
| 51 | - if ($val == true) |
|
| 52 | - return $this->db->insert_id(); |
|
| 53 | - else |
|
| 54 | - return $rs; |
|
| 51 | + if ($val == true) { |
|
| 52 | + return $this->db->insert_id(); |
|
| 53 | + } else { |
|
| 54 | + return $rs; |
|
| 55 | + } |
|
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | /* * ******************************************************** |
@@ -134,15 +135,18 @@ discard block |
||
| 134 | 135 | $this->db->where($where); |
| 135 | 136 | } |
| 136 | 137 | |
| 137 | - if ($paging_limit) |
|
| 138 | - $this->db->limit($paging_limit, $start_limit); |
|
| 139 | - if (!empty($groupby)) |
|
| 140 | - $this->db->group_by($groupby); |
|
| 138 | + if ($paging_limit) { |
|
| 139 | + $this->db->limit($paging_limit, $start_limit); |
|
| 140 | + } |
|
| 141 | + if (!empty($groupby)) { |
|
| 142 | + $this->db->group_by($groupby); |
|
| 143 | + } |
|
| 141 | 144 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
| 142 | 145 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
| 143 | - }else{ |
|
| 144 | - if($order_by) |
|
| 145 | - $this->db->order_by($order_by, $order_type); |
|
| 146 | + } else{ |
|
| 147 | + if($order_by) { |
|
| 148 | + $this->db->order_by($order_by, $order_type); |
|
| 149 | + } |
|
| 146 | 150 | } |
| 147 | 151 | $query = $this->db->get(); |
| 148 | 152 | return $query; |
@@ -160,10 +164,12 @@ discard block |
||
| 160 | 164 | } |
| 161 | 165 | $this->db->where_in($key, $where_in); |
| 162 | 166 | $this->db->order_by($order_by, $order_type); |
| 163 | - if ($paging_limit) |
|
| 164 | - $this->db->limit($paging_limit, $start_limit); |
|
| 165 | - if (!empty($groupby)) |
|
| 166 | - $this->db->groupby($groupby); |
|
| 167 | + if ($paging_limit) { |
|
| 168 | + $this->db->limit($paging_limit, $start_limit); |
|
| 169 | + } |
|
| 170 | + if (!empty($groupby)) { |
|
| 171 | + $this->db->groupby($groupby); |
|
| 172 | + } |
|
| 167 | 173 | $query = $this->db->get(); |
| 168 | 174 | |
| 169 | 175 | return $query; |
@@ -254,9 +260,10 @@ discard block |
||
| 254 | 260 | } |
| 255 | 261 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
| 256 | 262 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
| 257 | - }else{ |
|
| 258 | - if($order_by) |
|
| 259 | - $this->db->order_by($order_by, $order_type); |
|
| 263 | + } else{ |
|
| 264 | + if($order_by) { |
|
| 265 | + $this->db->order_by($order_by, $order_type); |
|
| 266 | + } |
|
| 260 | 267 | } |
| 261 | 268 | |
| 262 | 269 | if ($group_by != '') { |
@@ -306,9 +313,10 @@ discard block |
||
| 306 | 313 | } |
| 307 | 314 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
| 308 | 315 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
| 309 | - }else{ |
|
| 310 | - if($order_by) |
|
| 311 | - $this->db->order_by($order_by, $order_type); |
|
| 316 | + } else{ |
|
| 317 | + if($order_by) { |
|
| 318 | + $this->db->order_by($order_by, $order_type); |
|
| 319 | + } |
|
| 312 | 320 | } |
| 313 | 321 | |
| 314 | 322 | if ($group_by != '') { |
@@ -572,7 +580,7 @@ discard block |
||
| 572 | 580 | $name=explode("as",$select); |
| 573 | 581 | if(isset($name[3])){ |
| 574 | 582 | $name=trim($name[3]); |
| 575 | - }else{ |
|
| 583 | + } else{ |
|
| 576 | 584 | $name=trim($name[1]); |
| 577 | 585 | } |
| 578 | 586 | |
@@ -583,7 +591,7 @@ discard block |
||
| 583 | 591 | if(isset($dele[1])) |
| 584 | 592 | { |
| 585 | 593 | $drp_list['Deleted'][$drp_value->$select_params[0]] = str_replace("^","",$drp_value->$name); |
| 586 | - }else{ |
|
| 594 | + } else{ |
|
| 587 | 595 | $drp_list['Active'][$drp_value->$select_params[0]] = $drp_value->$name; |
| 588 | 596 | } |
| 589 | 597 | } |
@@ -645,7 +653,7 @@ discard block |
||
| 645 | 653 | if($field == 'invoice_date'){ |
| 646 | 654 | $this->db->where($field . ' >= ', gmdate("Y-m-d", strtotime($value['0']))." 00:00:01"); |
| 647 | 655 | $this->db->where($field . ' <= ', gmdate("Y-m-d", strtotime($value['0']))." 23:59:59"); |
| 648 | - }else{ |
|
| 656 | + } else{ |
|
| 649 | 657 | $this->db->where($field . ' >= ', gmdate('Y-m-d H:i:s',strtotime($value[0]))); |
| 650 | 658 | } |
| 651 | 659 | } |
@@ -734,20 +742,23 @@ discard block |
||
| 734 | 742 | if (array_key_exists($key . "-integer", $value)) { |
| 735 | 743 | $string=null; |
| 736 | 744 | $string =$this->build_interger_where($key, $value[$key . "-integer"], $value[$key]); |
| 737 | - if($string) |
|
| 738 | - $where.= "$string AND "; |
|
| 745 | + if($string) { |
|
| 746 | + $where.= "$string AND "; |
|
| 747 | + } |
|
| 739 | 748 | } |
| 740 | 749 | if (array_key_exists($key . "-string", $value)) { |
| 741 | 750 | $string=null; |
| 742 | 751 | $string=$this->build_string_where($key, $value[$key . "-string"], $value[$key]); |
| 743 | - if($string) |
|
| 744 | - $where.= "$string AND "; |
|
| 752 | + if($string) { |
|
| 753 | + $where.= "$string AND "; |
|
| 754 | + } |
|
| 745 | 755 | } |
| 746 | 756 | if ($key == 'callstart'|| $key == 'date'||$key== 'log_time') { |
| 747 | 757 | $string=null; |
| 748 | 758 | $string=$this->build_date_where($key, $value); |
| 749 | - if($string) |
|
| 750 | - $where.= "$string AND "; |
|
| 759 | + if($string) { |
|
| 760 | + $where.= "$string AND "; |
|
| 761 | + } |
|
| 751 | 762 | } |
| 752 | 763 | } else { |
| 753 | 764 | $where.="$key = '$value'AND "; |
@@ -779,14 +790,14 @@ discard block |
||
| 779 | 790 | case "5": |
| 780 | 791 | if($field == "pattern"){ |
| 781 | 792 | $where = $field . " LIKE '^".$search_array."%'"; |
| 782 | - }else{ |
|
| 793 | + } else{ |
|
| 783 | 794 | $where = $field . " LIKE '".$search_array."%'"; |
| 784 | 795 | } |
| 785 | 796 | break; |
| 786 | 797 | case "6": |
| 787 | 798 | if($field == "pattern"){ |
| 788 | 799 | $str1 = $field . " LIKE '%".$search_array.".*'"; |
| 789 | - }else{ |
|
| 800 | + } else{ |
|
| 790 | 801 | $str1 = $field . " LIKE '%".$search_array."'"; |
| 791 | 802 | } |
| 792 | 803 | break; |
@@ -820,8 +831,7 @@ discard block |
||
| 820 | 831 | $where = "$field <= '$search_array'"; |
| 821 | 832 | break; |
| 822 | 833 | } |
| 823 | - } |
|
| 824 | - else |
|
| 834 | + } else |
|
| 825 | 835 | { |
| 826 | 836 | $this->db->where("$field IS NULL"); |
| 827 | 837 | $where= "$field IS NULL"; |
@@ -835,14 +845,16 @@ discard block |
||
| 835 | 845 | if (!empty($value[0])) { |
| 836 | 846 | $string=null; |
| 837 | 847 | $string="$field >= '$value[0]'"; |
| 838 | - if($string) |
|
| 839 | - $where.=$string." AND "; |
|
| 848 | + if($string) { |
|
| 849 | + $where.=$string." AND "; |
|
| 850 | + } |
|
| 840 | 851 | } |
| 841 | 852 | if (!empty($value[1])) { |
| 842 | 853 | $string=null; |
| 843 | 854 | $string="$field <= '$value[1]'"; |
| 844 | - if($string) |
|
| 845 | - $where.=$string." AND "; |
|
| 855 | + if($string) { |
|
| 856 | + $where.=$string." AND "; |
|
| 857 | + } |
|
| 846 | 858 | } |
| 847 | 859 | } |
| 848 | 860 | if($where){ |
@@ -994,9 +1006,9 @@ discard block |
||
| 994 | 1006 | if($drp_value->type == 3) |
| 995 | 1007 | { |
| 996 | 1008 | $drp_list['Provider'][$drp_value->id] = $drp_value->first_name; |
| 997 | - }elseif($drp_value->type == 1){ |
|
| 1009 | + } elseif($drp_value->type == 1){ |
|
| 998 | 1010 | $drp_list['Reseller'][$drp_value->id] = $drp_value->first_name; |
| 999 | - }else{ |
|
| 1011 | + } else{ |
|
| 1000 | 1012 | $drp_list['Customer'][$drp_value->id] = $drp_value->first_name; |
| 1001 | 1013 | } |
| 1002 | 1014 | } |
@@ -23,33 +23,33 @@ |
||
| 23 | 23 | |
| 24 | 24 | class Auth_model extends CI_Model { |
| 25 | 25 | |
| 26 | - function Auth_model() { |
|
| 27 | - parent::__construct(); |
|
| 28 | - } |
|
| 29 | - /** |
|
| 30 | - * -------Here we write code for model auth_model functions verify_login------ |
|
| 31 | - * Purpose: Validate Login Name and Password. |
|
| 32 | - * @param $username,$password. |
|
| 33 | - * @return integer login user name and password is valid then return true else return false. |
|
| 34 | - */ |
|
| 35 | - function verify_login($username, $password) { |
|
| 36 | - $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
|
| 26 | + function Auth_model() { |
|
| 27 | + parent::__construct(); |
|
| 28 | + } |
|
| 29 | + /** |
|
| 30 | + * -------Here we write code for model auth_model functions verify_login------ |
|
| 31 | + * Purpose: Validate Login Name and Password. |
|
| 32 | + * @param $username,$password. |
|
| 33 | + * @return integer login user name and password is valid then return true else return false. |
|
| 34 | + */ |
|
| 35 | + function verify_login($username, $password) { |
|
| 36 | + $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
|
| 37 | 37 | $q .= " OR email = '".$this->db->escape_str($username)."')"; |
| 38 | - $q .= " AND password = '".$this->db->escape_str($password)."'"; |
|
| 39 | - $q .= " AND status = 0 AND type IN (1,2,3,4,5,0,-1) AND deleted = 0"; |
|
| 40 | - $query = $this->db->query($q); |
|
| 41 | - if ($query->num_rows() > 0) { |
|
| 42 | - $row = $query->row(); |
|
| 43 | - if ($row->cnt > 0) { |
|
| 44 | - $this->session->set_userdata('user_name', $username); |
|
| 45 | - return 1; |
|
| 46 | - } else { |
|
| 47 | - return 0; |
|
| 48 | - } |
|
| 49 | - } |
|
| 38 | + $q .= " AND password = '".$this->db->escape_str($password)."'"; |
|
| 39 | + $q .= " AND status = 0 AND type IN (1,2,3,4,5,0,-1) AND deleted = 0"; |
|
| 40 | + $query = $this->db->query($q); |
|
| 41 | + if ($query->num_rows() > 0) { |
|
| 42 | + $row = $query->row(); |
|
| 43 | + if ($row->cnt > 0) { |
|
| 44 | + $this->session->set_userdata('user_name', $username); |
|
| 45 | + return 1; |
|
| 46 | + } else { |
|
| 47 | + return 0; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - return 0; |
|
| 52 | - } |
|
| 51 | + return 0; |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | //end class |
@@ -127,8 +127,9 @@ discard block |
||
| 127 | 127 | $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
| 128 | 128 | $amount = str_replace( ',', '', $amount ); |
| 129 | 129 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
| 130 | - if ($format_currency) |
|
| 131 | - $cal_amount = $this->format_currency($cal_amount); |
|
| 130 | + if ($format_currency) { |
|
| 131 | + $cal_amount = $this->format_currency($cal_amount); |
|
| 132 | + } |
|
| 132 | 133 | if ($append_currency){ |
| 133 | 134 | $cal_amount = $cal_amount . " " . $to_currency; |
| 134 | 135 | } |
@@ -146,10 +147,12 @@ discard block |
||
| 146 | 147 | $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
| 147 | 148 | $amount = str_replace( ',', '', $amount ); |
| 148 | 149 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
| 149 | - if ($format_currency) |
|
| 150 | - $cal_amount = $this->format_currency($cal_amount); |
|
| 151 | - if ($append_currency) |
|
| 152 | - $cal_amount = $cal_amount ; |
|
| 150 | + if ($format_currency) { |
|
| 151 | + $cal_amount = $this->format_currency($cal_amount); |
|
| 152 | + } |
|
| 153 | + if ($append_currency) { |
|
| 154 | + $cal_amount = $cal_amount ; |
|
| 155 | + } |
|
| 153 | 156 | $cal_amount = str_replace( ',', '', $cal_amount ); |
| 154 | 157 | return $cal_amount; |
| 155 | 158 | } |
@@ -163,13 +166,15 @@ discard block |
||
| 163 | 166 | $to_currency = ($to_currency == '') ? self::$global_config['system_config']['base_currency'] : $to_currency; |
| 164 | 167 | if(self::$global_config['currency_list'][$from_currency] > 0){ |
| 165 | 168 | $cal_amount = ($amount * self::$global_config['currency_list'][$to_currency]) / self::$global_config['currency_list'][$from_currency]; |
| 166 | - }else{ |
|
| 169 | + } else{ |
|
| 167 | 170 | $cal_amount=$amount; |
| 168 | 171 | } |
| 169 | - if ($format_currency) |
|
| 170 | - $cal_amount = $this->format_currency($cal_amount); |
|
| 171 | - if ($append_currency) |
|
| 172 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
| 172 | + if ($format_currency) { |
|
| 173 | + $cal_amount = $this->format_currency($cal_amount); |
|
| 174 | + } |
|
| 175 | + if ($append_currency) { |
|
| 176 | + $cal_amount = $cal_amount . " " . $to_currency; |
|
| 177 | + } |
|
| 173 | 178 | $cal_amount = str_replace( ',', '', $cal_amount ); |
| 174 | 179 | return $cal_amount; |
| 175 | 180 | } |
@@ -185,10 +190,12 @@ discard block |
||
| 185 | 190 | $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
| 186 | 191 | $amount = str_replace( ',', '', $amount ); |
| 187 | 192 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
| 188 | - if ($format_currency) |
|
| 189 | - $cal_amount = $this->format_currency($cal_amount); |
|
| 190 | - if ($append_currency) |
|
| 191 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
| 193 | + if ($format_currency) { |
|
| 194 | + $cal_amount = $this->format_currency($cal_amount); |
|
| 195 | + } |
|
| 196 | + if ($append_currency) { |
|
| 197 | + $cal_amount = $cal_amount . " " . $to_currency; |
|
| 198 | + } |
|
| 192 | 199 | $cal_amount = str_replace( ',', '', $cal_amount ); |
| 193 | 200 | return $cal_amount; |
| 194 | 201 | } |
@@ -318,7 +325,7 @@ discard block |
||
| 318 | 325 | $account_result=(array)$account_result->first_row(); |
| 319 | 326 | if(isset($account_result['reseller_id']) && $account_result['reseller_id']> 0){ |
| 320 | 327 | return $account_result['reseller_id']; |
| 321 | - }else{ |
|
| 328 | + } else{ |
|
| 322 | 329 | return '0'; |
| 323 | 330 | } |
| 324 | 331 | |
@@ -38,27 +38,34 @@ |
||
| 38 | 38 | public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') {
|
| 39 | 39 | |
| 40 | 40 | if (is_array($langfile)) {
|
| 41 | - foreach ($langfile as $_lang) $this->load($_lang); |
|
| 41 | + foreach ($langfile as $_lang) { |
|
| 42 | + $this->load($_lang); |
|
| 43 | + } |
|
| 42 | 44 | return $this->language; |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | $deft_lang = CI::$APP->config->item('language');
|
| 46 | 48 | $idiom = ($lang == '') ? $deft_lang : $lang; |
| 47 | 49 | |
| 48 | - if (in_array($langfile.'_lang'.EXT, $this->is_loaded, TRUE)) |
|
| 49 | - return $this->language; |
|
| 50 | + if (in_array($langfile.'_lang'.EXT, $this->is_loaded, TRUE)) { |
|
| 51 | + return $this->language; |
|
| 52 | + } |
|
| 50 | 53 | |
| 51 | 54 | $_module OR $_module = CI::$APP->router->fetch_module(); |
| 52 | 55 | list($path, $_langfile) = Modules::find($langfile.'_lang', $_module, 'language/'.$idiom.'/'); |
| 53 | 56 | |
| 54 | 57 | if ($path === FALSE) {
|
| 55 | 58 | |
| 56 | - if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) return $lang; |
|
| 59 | + if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) { |
|
| 60 | + return $lang; |
|
| 61 | + } |
|
| 57 | 62 | |
| 58 | 63 | } else {
|
| 59 | 64 | |
| 60 | 65 | if ($lang = Modules::load_file($_langfile, $path, 'lang')) {
|
| 61 | - if ($return) return $lang; |
|
| 66 | + if ($return) { |
|
| 67 | + return $lang; |
|
| 68 | + } |
|
| 62 | 69 | $this->language = array_merge($this->language, $lang); |
| 63 | 70 | $this->is_loaded[] = $langfile.'_lang'.EXT; |
| 64 | 71 | unset($lang); |
@@ -141,18 +141,23 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | public function languages($languages) {
|
| 144 | - foreach ($languages as $_language) $this->language($_language); |
|
| 144 | + foreach ($languages as $_language) { |
|
| 145 | + $this->language($_language); |
|
| 146 | + } |
|
| 145 | 147 | } |
| 146 | 148 | |
| 147 | 149 | /** Load a module library **/ |
| 148 | 150 | public function library($library = '', $params = NULL, $object_name = NULL) {
|
| 149 | 151 | |
| 150 | - if (is_array($library)) return $this->libraries($library); |
|
| 152 | + if (is_array($library)) { |
|
| 153 | + return $this->libraries($library); |
|
| 154 | + } |
|
| 151 | 155 | |
| 152 | 156 | $class = strtolower(basename($library)); |
| 153 | 157 | |
| 154 | - if (isset($this->_ci_classes[$class]) AND $_alias = $this->_ci_classes[$class]) |
|
| 155 | - return CI::$APP->$_alias; |
|
| 158 | + if (isset($this->_ci_classes[$class]) AND $_alias = $this->_ci_classes[$class]) { |
|
| 159 | + return CI::$APP->$_alias; |
|
| 160 | + } |
|
| 156 | 161 | |
| 157 | 162 | ($_alias = strtolower($object_name)) OR $_alias = $class; |
| 158 | 163 | |
@@ -234,13 +239,17 @@ discard block |
||
| 234 | 239 | |
| 235 | 240 | /** Load an array of models **/ |
| 236 | 241 | public function models($models) {
|
| 237 | - foreach ($models as $_model) $this->model($_model); |
|
| 242 | + foreach ($models as $_model) { |
|
| 243 | + $this->model($_model); |
|
| 244 | + } |
|
| 238 | 245 | } |
| 239 | 246 | |
| 240 | 247 | /** Load a module controller **/ |
| 241 | 248 | public function module($module, $params = NULL) {
|
| 242 | 249 | |
| 243 | - if (is_array($module)) return $this->modules($module); |
|
| 250 | + if (is_array($module)) { |
|
| 251 | + return $this->modules($module); |
|
| 252 | + } |
|
| 244 | 253 | |
| 245 | 254 | $_alias = strtolower(basename($module)); |
| 246 | 255 | CI::$APP->$_alias = Modules::load(array($module => $params)); |
@@ -249,16 +258,21 @@ discard block |
||
| 249 | 258 | |
| 250 | 259 | /** Load an array of controllers **/ |
| 251 | 260 | public function modules($modules) {
|
| 252 | - foreach ($modules as $_module) $this->module($_module); |
|
| 261 | + foreach ($modules as $_module) { |
|
| 262 | + $this->module($_module); |
|
| 263 | + } |
|
| 253 | 264 | } |
| 254 | 265 | |
| 255 | 266 | /** Load a module plugin **/ |
| 256 | 267 | public function plugin($plugin) {
|
| 257 | 268 | |
| 258 | - if (is_array($plugin)) return $this->plugins($plugin); |
|
| 269 | + if (is_array($plugin)) { |
|
| 270 | + return $this->plugins($plugin); |
|
| 271 | + } |
|
| 259 | 272 | |
| 260 | - if (isset($this->_ci_plugins[$plugin])) |
|
| 261 | - return; |
|
| 273 | + if (isset($this->_ci_plugins[$plugin])) { |
|
| 274 | + return; |
|
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | list($path, $_plugin) = Modules::find($plugin.'_pi', $this->_module, 'plugins/'); |
| 264 | 278 | |
@@ -314,20 +328,26 @@ discard block |
||
| 314 | 328 | break; |
| 315 | 329 | } |
| 316 | 330 | |
| 317 | - if ( ! $cascade) break; |
|
| 331 | + if ( ! $cascade) { |
|
| 332 | + break; |
|
| 333 | + } |
|
| 318 | 334 | } |
| 319 | 335 | |
| 320 | 336 | } elseif (isset($_ci_path)) {
|
| 321 | 337 | |
| 322 | 338 | $_ci_file = basename($_ci_path); |
| 323 | - if ( ! file_exists($_ci_path)) $_ci_path = ''; |
|
| 339 | + if ( ! file_exists($_ci_path)) { |
|
| 340 | + $_ci_path = ''; |
|
| 341 | + } |
|
| 324 | 342 | } |
| 325 | 343 | |
| 326 | - if (empty($_ci_path)) |
|
| 327 | - show_error('Unable to load the requested file: '.$_ci_file);
|
|
| 344 | + if (empty($_ci_path)) { |
|
| 345 | + show_error('Unable to load the requested file: '.$_ci_file); |
|
| 346 | + } |
|
| 328 | 347 | |
| 329 | - if (isset($_ci_vars)) |
|
| 330 | - $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, (array)$_ci_vars); |
|
| 348 | + if (isset($_ci_vars)) { |
|
| 349 | + $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, (array)$_ci_vars); |
|
| 350 | + } |
|
| 331 | 351 | |
| 332 | 352 | extract($this->_ci_cached_vars); |
| 333 | 353 | |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | function __construct() |
| 42 | 42 | { |
| 43 | 43 | parent::__construct(); |
| 44 | - if ( ! defined('CRON')) |
|
| 45 | - exit(); |
|
| 44 | + if ( ! defined('CRON')) { |
|
| 45 | + exit(); |
|
| 46 | + } |
|
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | |
@@ -76,8 +77,9 @@ discard block |
||
| 76 | 77 | function generate_sitemap() |
| 77 | 78 | { |
| 78 | 79 | // Live Mode: |
| 79 | - if ( ! CRON_BETA_MODE) |
|
| 80 | - $cron_id = $this->cron->create('Sitemap (Google|Bing|Ask|Yahoo!)'); |
|
| 80 | + if ( ! CRON_BETA_MODE) { |
|
| 81 | + $cron_id = $this->cron->create('Sitemap (Google|Bing|Ask|Yahoo!)'); |
|
| 82 | + } |
|
| 81 | 83 | |
| 82 | 84 | // Example Code |
| 83 | 85 | |
@@ -89,8 +91,9 @@ discard block |
||
| 89 | 91 | // ... |
| 90 | 92 | |
| 91 | 93 | // Sandbox Mode: |
| 92 | - if (CRON_BETA_MODE) |
|
| 93 | - $this->sitemap->generate_xml(null, false); |
|
| 94 | + if (CRON_BETA_MODE) { |
|
| 95 | + $this->sitemap->generate_xml(null, false); |
|
| 96 | + } |
|
| 94 | 97 | |
| 95 | 98 | // Live Mode: |
| 96 | 99 | else { |
@@ -37,8 +37,7 @@ |
||
| 37 | 37 | if($opensips_flag == '1'){ |
| 38 | 38 | $where=array('username'=>$sipnumber); |
| 39 | 39 | $accountid_arr=$this->db_model->getSelect('accountid','sip_devices',$where); |
| 40 | - } |
|
| 41 | - else{ |
|
| 40 | + } else{ |
|
| 42 | 41 | $db_config = Common_model::$global_config['system_config']; |
| 43 | 42 | $opensipdsn = "mysql://" . $db_config['opensips_dbuser'] . ":" . $db_config['opensips_dbpass'] . "@" . $db_config['opensips_dbhost'] . "/" . $db_config['opensips_dbname'] . "?char_set=utf8&dbcollat=utf8_general_ci&cache_on=true&cachedir="; |
| 44 | 43 | $this->opensips_db = $this->load->database($opensipdsn, true); |