| @@ -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 | ?> | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | |
| 125 | 125 | $amount_operator = $taxes_search['amount_operator']; | 
| 126 | 126 | |
| 127 | -			if (!empty($taxes_search['amount'])) { | |
| 127 | +			if ( ! empty($taxes_search['amount'])) { | |
| 128 | 128 |  				switch ($amount_operator) { | 
| 129 | 129 | case "1": | 
| 130 | 130 |  						$this->db->where('taxes_amount ', $taxes_search['amount']); | 
| @@ -149,7 +149,7 @@ discard block | ||
| 149 | 149 | |
| 150 | 150 | $rate_operator = $taxes_search['rate_operator']; | 
| 151 | 151 | |
| 152 | -			if (!empty($taxes_search['rate'])) { | |
| 152 | +			if ( ! empty($taxes_search['rate'])) { | |
| 153 | 153 |  				switch ($rate_operator) { | 
| 154 | 154 | case "1": | 
| 155 | 155 |  						$this->db->where('taxes_rate ', $taxes_search['rate']); | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 | } | 
| 174 | 174 | |
| 175 | 175 | $description_operator = $taxes_search['description_operator']; | 
| 176 | -			if (!empty($taxes_search['description'])) { | |
| 176 | +			if ( ! empty($taxes_search['description'])) { | |
| 177 | 177 |  				switch ($description_operator) { | 
| 178 | 178 | case "1": | 
| 179 | 179 |  						$this->db->like('taxes_description', $taxes_search['description']); | 
| @@ -202,7 +202,7 @@ discard block | ||
| 202 | 202 | |
| 203 | 203 | $amount_operator = $taxes_search['amount_operator']; | 
| 204 | 204 | |
| 205 | -			if (!empty($taxes_search['amount'])) { | |
| 205 | +			if ( ! empty($taxes_search['amount'])) { | |
| 206 | 206 |  				switch ($amount_operator) { | 
| 207 | 207 | case "1": | 
| 208 | 208 |  						$this->db->where('taxes_amount =', $taxes_search['amount']); | 
| @@ -227,7 +227,7 @@ discard block | ||
| 227 | 227 | |
| 228 | 228 | $rate_operator = $taxes_search['rate_operator']; | 
| 229 | 229 | |
| 230 | -			if (!empty($taxes_search['rate'])) { | |
| 230 | +			if ( ! empty($taxes_search['rate'])) { | |
| 231 | 231 |  				switch ($rate_operator) { | 
| 232 | 232 | case "1": | 
| 233 | 233 |  						$this->db->where('taxes_rate == ', $taxes_search['rate']); | 
| @@ -251,7 +251,7 @@ discard block | ||
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | 253 | $description_operator = $taxes_search['description_operator']; | 
| 254 | -			if (!empty($taxes_search['description'])) { | |
| 254 | +			if ( ! empty($taxes_search['description'])) { | |
| 255 | 255 |  				switch ($description_operator) { | 
| 256 | 256 | case "1": | 
| 257 | 257 |  						$this->db->like('taxes_description', $taxes_search['description']); | 
| @@ -299,7 +299,7 @@ discard block | ||
| 299 | 299 | $template_name_operator = $templatesearch['template_name_operator']; | 
| 300 | 300 | |
| 301 | 301 | |
| 302 | -			if (!empty($templatesearch['template_name'])) { | |
| 302 | +			if ( ! empty($templatesearch['template_name'])) { | |
| 303 | 303 |  				switch ($template_name_operator) { | 
| 304 | 304 | case "1": | 
| 305 | 305 |  						$this->db->like('name', $templatesearch['template_name']); | 
| @@ -317,7 +317,7 @@ discard block | ||
| 317 | 317 | } | 
| 318 | 318 | |
| 319 | 319 | $template_subject = $templatesearch['subject_operator']; | 
| 320 | -			if (!empty($templatesearch['subject'])) { | |
| 320 | +			if ( ! empty($templatesearch['subject'])) { | |
| 321 | 321 |  				switch ($template_subject) { | 
| 322 | 322 | case "1": | 
| 323 | 323 |  						$this->db->like('subject', $templatesearch['subject']); | 
| @@ -334,7 +334,7 @@ discard block | ||
| 334 | 334 | } | 
| 335 | 335 | } | 
| 336 | 336 | $template_op = $templatesearch['template_operator']; | 
| 337 | -			if (!empty($templatesearch['template_desc'])) { | |
| 337 | +			if ( ! empty($templatesearch['template_desc'])) { | |
| 338 | 338 | |
| 339 | 339 |  				switch ($template_op) { | 
| 340 | 340 | case "1": | 
| @@ -353,7 +353,7 @@ discard block | ||
| 353 | 353 | } | 
| 354 | 354 | |
| 355 | 355 | |
| 356 | -			if (!empty($templatesearch['accountid'])) { | |
| 356 | +			if ( ! empty($templatesearch['accountid'])) { | |
| 357 | 357 |  				$this->db->like('accountid', $templatesearch['accountid']); | 
| 358 | 358 | } | 
| 359 | 359 | } | 
| @@ -395,19 +395,19 @@ discard block | ||
| 395 | 395 |  		if ($this->session->userdata('advance_search') == 1) { | 
| 396 | 396 |  			$configuration_search = $this->session->userdata('configuration_search'); | 
| 397 | 397 | |
| 398 | -			if (!empty($configuration_search['reseller'])) { | |
| 398 | +			if ( ! empty($configuration_search['reseller'])) { | |
| 399 | 399 |  				$this->db->where('reseller ', $configuration_search['reseller']); | 
| 400 | 400 | } | 
| 401 | -			if (!empty($configuration_search['brand'])) { | |
| 401 | +			if ( ! empty($configuration_search['brand'])) { | |
| 402 | 402 |  				$this->db->where('brand', $configuration_search['brand']); | 
| 403 | 403 | } | 
| 404 | -			if (!empty($configuration_search['group_title'])) { | |
| 404 | +			if ( ! empty($configuration_search['group_title'])) { | |
| 405 | 405 |  				$this->db->where('group_title', $configuration_search['group_title']); | 
| 406 | 406 | } | 
| 407 | 407 | |
| 408 | 408 | $name_operator = $configuration_search['name_operator']; | 
| 409 | 409 | |
| 410 | -			if (!empty($configuration_search['name'])) { | |
| 410 | +			if ( ! empty($configuration_search['name'])) { | |
| 411 | 411 |  				switch ($name_operator) { | 
| 412 | 412 | case "1": | 
| 413 | 413 |  						$this->db->like('name', $configuration_search['name']); | 
| @@ -426,7 +426,7 @@ discard block | ||
| 426 | 426 | |
| 427 | 427 | $value_operator = $configuration_search['value_operator']; | 
| 428 | 428 | |
| 429 | -			if (!empty($configuration_search['value'])) { | |
| 429 | +			if ( ! empty($configuration_search['value'])) { | |
| 430 | 430 |  				switch ($value_operator) { | 
| 431 | 431 | case "1": | 
| 432 | 432 |  						$this->db->like('value', $configuration_search['value']); | 
| @@ -445,7 +445,7 @@ discard block | ||
| 445 | 445 | |
| 446 | 446 | $comment_operator = $configuration_search['comment_operator']; | 
| 447 | 447 | |
| 448 | -			if (!empty($configuration_search['comment'])) { | |
| 448 | +			if ( ! empty($configuration_search['comment'])) { | |
| 449 | 449 |  				switch ($comment_operator) { | 
| 450 | 450 | case "1": | 
| 451 | 451 |  						$this->db->like('comment', $configuration_search['comment']); | 
| @@ -86,7 +86,7 @@ discard block | ||
| 86 | 86 | $this->db->select($select); | 
| 87 | 87 | $this->db->from($tableName); | 
| 88 | 88 | $this->db->where($where); | 
| 89 | - $this->db->order_by($order_by,$order_type); | |
| 89 | + $this->db->order_by($order_by, $order_type); | |
| 90 | 90 | $query = $this->db->get(); | 
| 91 | 91 | return $query; | 
| 92 | 92 | } | 
| @@ -136,12 +136,12 @@ discard block | ||
| 136 | 136 | |
| 137 | 137 | if ($paging_limit) | 
| 138 | 138 | $this->db->limit($paging_limit, $start_limit); | 
| 139 | - if (!empty($groupby)) | |
| 139 | + if ( ! empty($groupby)) | |
| 140 | 140 | $this->db->group_by($groupby); | 
| 141 | -		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ | |
| 142 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); | |
| 143 | -		}else{ | |
| 144 | - if($order_by) | |
| 141 | +		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { | |
| 142 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); | |
| 143 | +		} else { | |
| 144 | + if ($order_by) | |
| 145 | 145 | $this->db->order_by($order_by, $order_type); | 
| 146 | 146 | } | 
| 147 | 147 | $query = $this->db->get(); | 
| @@ -162,7 +162,7 @@ discard block | ||
| 162 | 162 | $this->db->order_by($order_by, $order_type); | 
| 163 | 163 | if ($paging_limit) | 
| 164 | 164 | $this->db->limit($paging_limit, $start_limit); | 
| 165 | - if (!empty($groupby)) | |
| 165 | + if ( ! empty($groupby)) | |
| 166 | 166 | $this->db->groupby($groupby); | 
| 167 | 167 | $query = $this->db->get(); | 
| 168 | 168 | |
| @@ -192,7 +192,7 @@ discard block | ||
| 192 | 192 |  		if ($where != "") { | 
| 193 | 193 | $this->db->where($where); | 
| 194 | 194 | } | 
| 195 | -		if (!empty($where_in)) { | |
| 195 | +		if ( ! empty($where_in)) { | |
| 196 | 196 | $this->db->where_in($key, $where_in); | 
| 197 | 197 | } | 
| 198 | 198 | $this->db->from($table); | 
| @@ -244,18 +244,18 @@ discard block | ||
| 244 | 244 | * ******************************************************** */ | 
| 245 | 245 | |
| 246 | 246 |  	function getJionQuery($table, $feild, $where = "", $jionTable, $jionCondition, $type = 'inner', $start = '', $end = '', $order_type = '', $order_by = '', $group_by = '') { | 
| 247 | - $start = (int) $start; | |
| 248 | - $end = (int) $end; | |
| 247 | + $start = (int)$start; | |
| 248 | + $end = (int)$end; | |
| 249 | 249 | $this->db->select($feild); | 
| 250 | 250 | $this->db->from($table); | 
| 251 | 251 | $this->db->join($jionTable, $jionCondition, $type); | 
| 252 | 252 |  		if ($where != "") { | 
| 253 | 253 | $this->db->where($where); | 
| 254 | 254 | } | 
| 255 | -		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ | |
| 256 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); | |
| 257 | -		}else{ | |
| 258 | - if($order_by) | |
| 255 | +		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { | |
| 256 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); | |
| 257 | +		} else { | |
| 258 | + if ($order_by) | |
| 259 | 259 | $this->db->order_by($order_by, $order_type); | 
| 260 | 260 | } | 
| 261 | 261 | |
| @@ -269,8 +269,8 @@ discard block | ||
| 269 | 269 | } | 
| 270 | 270 | |
| 271 | 271 |  	function getJionQueryCount($table, $feild, $where = "", $jionTable, $jionCondition, $type = 'inner', $start = '', $end = '', $order_type = '', $order_by = '', $group_by = '') { | 
| 272 | - $start = (int) $start; | |
| 273 | - $end = (int) $end; | |
| 272 | + $start = (int)$start; | |
| 273 | + $end = (int)$end; | |
| 274 | 274 | $this->db->select($feild); | 
| 275 | 275 | $this->db->from($table); | 
| 276 | 276 | $this->db->join($jionTable, $jionCondition, $type); | 
| @@ -292,8 +292,8 @@ discard block | ||
| 292 | 292 | } | 
| 293 | 293 | |
| 294 | 294 |  	function getAllJionQuery($table, $feild, $where = "", $jionTable, $jionCondition, $type, $start = '', $end = '', $order_type = '', $order_by = '', $group_by = '') { | 
| 295 | - $start = (int) $start; | |
| 296 | - $end = (int) $end; | |
| 295 | + $start = (int)$start; | |
| 296 | + $end = (int)$end; | |
| 297 | 297 | $this->db->select($feild); | 
| 298 | 298 | $this->db->from($table); | 
| 299 | 299 | $jion_table_count = count($jionTable); | 
| @@ -304,10 +304,10 @@ discard block | ||
| 304 | 304 |  		if ($where != "") { | 
| 305 | 305 | $this->db->where($where); | 
| 306 | 306 | } | 
| 307 | -		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ | |
| 308 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); | |
| 309 | -		}else{ | |
| 310 | - if($order_by) | |
| 307 | +		if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { | |
| 308 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); | |
| 309 | +		} else { | |
| 310 | + if ($order_by) | |
| 311 | 311 | $this->db->order_by($order_by, $order_type); | 
| 312 | 312 | } | 
| 313 | 313 | |
| @@ -406,7 +406,7 @@ discard block | ||
| 406 | 406 | $string = ''; | 
| 407 | 407 |  			if ($query->num_rows() > 0) { | 
| 408 | 408 |  				foreach ($query->result() as $rows) { | 
| 409 | - $string .= $rows->$select . ','; | |
| 409 | + $string .= $rows->$select.','; | |
| 410 | 410 | } | 
| 411 | 411 | |
| 412 | 412 | return substr($string, '', -1); | 
| @@ -429,13 +429,13 @@ discard block | ||
| 429 | 429 |  		} else { | 
| 430 | 430 |  			$cnt_str = " $select_params[1],' (',$select_params[2],')' "; | 
| 431 | 431 | } | 
| 432 | - $select = $select_params[0] . ", concat($cnt_str) as $select_params[1] "; | |
| 432 | + $select = $select_params[0].", concat($cnt_str) as $select_params[1] "; | |
| 433 | 433 |  		$logintype = $this->session->userdata('logintype'); | 
| 434 | 434 |  		if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr') { | 
| 435 | 435 |  			$account_data = $this->session->userdata("accountinfo"); | 
| 436 | 436 | $id_value['reseller_id'] = $account_data['id']; | 
| 437 | 437 | } | 
| 438 | -		if(isset($id_value['type']) && $id_value['type'] == '0,3'){ | |
| 438 | +		if (isset($id_value['type']) && $id_value['type'] == '0,3') { | |
| 439 | 439 |  			$twhere = "type IN (".$id_value["type"].")"; | 
| 440 | 440 | $this->db->where($twhere); | 
| 441 | 441 | unset($id_value['type']); | 
| @@ -488,7 +488,7 @@ discard block | ||
| 488 | 488 |  		} else { | 
| 489 | 489 |  			$cnt_str = " $select_params[1],' (',$select_params[2],')' "; | 
| 490 | 490 | } | 
| 491 | - $select = $select_params[0] . ", concat($cnt_str) as $select_params[1] "; | |
| 491 | + $select = $select_params[0].", concat($cnt_str) as $select_params[1] "; | |
| 492 | 492 | $where = $id_value; | 
| 493 | 493 | $drp_array = $this->getSelect($select, $table, $id_value); | 
| 494 | 494 | $drp_array = $drp_array->result(); | 
| @@ -503,7 +503,7 @@ discard block | ||
| 503 | 503 |  	function build_dropdown($select, $table, $id_where = '', $id_value = '') { | 
| 504 | 504 |  		$select_params = explode(',', $select); | 
| 505 | 505 | $where = ''; | 
| 506 | -		if(isset($id_value["type"]) && $id_value["type"] == "GLOBAL"){ | |
| 506 | +		if (isset($id_value["type"]) && $id_value["type"] == "GLOBAL") { | |
| 507 | 507 |  			$where = "type IN ('0','3')"; | 
| 508 | 508 | $this->db->where($where); | 
| 509 | 509 | unset($id_value["type"]); | 
| @@ -513,7 +513,7 @@ discard block | ||
| 513 | 513 | $this->db->group_by($id_value); | 
| 514 | 514 |  			} else if ($id_where == "where_arr") { | 
| 515 | 515 |  				$logintype = $this->session->userdata('logintype'); | 
| 516 | -				if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr' && $this->db->field_exists('reseller_id',$table)) { | |
| 516 | +				if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr' && $this->db->field_exists('reseller_id', $table)) { | |
| 517 | 517 | $id_value['reseller_id'] = $this->session->userdata["accountinfo"]['id']; | 
| 518 | 518 | } | 
| 519 | 519 | $where = $id_value; | 
| @@ -538,8 +538,8 @@ discard block | ||
| 538 | 538 | } | 
| 539 | 539 |    function build_dropdown_deleted($select, $table, $id_where = '', $id_value = '') { | 
| 540 | 540 |  		$select_params = explode(',', $select); | 
| 541 | -		if(isset($id_value["type"]) ){ | |
| 542 | -			$where = $id_value["type"] == "GLOBAL" ? "type IN ('0','3')": "type IN (".$id_value["type"].")"; | |
| 541 | +		if (isset($id_value["type"])) { | |
| 542 | +			$where = $id_value["type"] == "GLOBAL" ? "type IN ('0','3')" : "type IN (".$id_value["type"].")"; | |
| 543 | 543 | $this->db->where($where); | 
| 544 | 544 | unset($id_value["type"]); | 
| 545 | 545 | } | 
| @@ -569,21 +569,21 @@ discard block | ||
| 569 | 569 | |
| 570 | 570 | $drp_array = $drp_array->result(); | 
| 571 | 571 | |
| 572 | -		$name=explode("as",$select); | |
| 573 | -		if(isset($name[3])){ | |
| 574 | - $name=trim($name[3]); | |
| 575 | -		}else{ | |
| 576 | - $name=trim($name[1]); | |
| 572 | +		$name = explode("as", $select); | |
| 573 | +		if (isset($name[3])) { | |
| 574 | + $name = trim($name[3]); | |
| 575 | +		} else { | |
| 576 | + $name = trim($name[1]); | |
| 577 | 577 | } | 
| 578 | 578 | |
| 579 | 579 | $drp_list = array(); | 
| 580 | - $dele =array(); | |
| 580 | + $dele = array(); | |
| 581 | 581 |  		foreach ($drp_array as $drp_value) { | 
| 582 | -			$dele=explode("^",$drp_value->$name); | |
| 583 | - if(isset($dele[1])) | |
| 582 | +			$dele = explode("^", $drp_value->$name); | |
| 583 | + if (isset($dele[1])) | |
| 584 | 584 |  			{ | 
| 585 | -			   $drp_list['Deleted'][$drp_value->$select_params[0]] =  str_replace("^","",$drp_value->$name); | |
| 586 | -			}else{ | |
| 585 | +			   $drp_list['Deleted'][$drp_value->$select_params[0]] = str_replace("^", "", $drp_value->$name); | |
| 586 | +			} else { | |
| 587 | 587 | $drp_list['Active'][$drp_value->$select_params[0]] = $drp_value->$name; | 
| 588 | 588 | } | 
| 589 | 589 | } | 
| @@ -599,32 +599,32 @@ discard block | ||
| 599 | 599 | /* ASTPP 3.0 | 
| 600 | 600 | Display Records in | 
| 601 | 601 | */ | 
| 602 | - unset($account_search['search_in'],$account_search['time']); | |
| 603 | -			if (!empty($account_search)) { | |
| 602 | + unset($account_search['search_in'], $account_search['time']); | |
| 603 | +			if ( ! empty($account_search)) { | |
| 604 | 604 |  				foreach ($account_search as $key => $value) { | 
| 605 | 605 |  					if ($value != "") { | 
| 606 | 606 |  						if (is_array($value)) { | 
| 607 | -							if (array_key_exists($key . "-integer", $value)) { | |
| 608 | - $this->get_interger_array($key, $value[$key . "-integer"], $value[$key]); | |
| 607 | +							if (array_key_exists($key."-integer", $value)) { | |
| 608 | + $this->get_interger_array($key, $value[$key."-integer"], $value[$key]); | |
| 609 | 609 | } | 
| 610 | -							if (array_key_exists($key . "-string", $value)) { | |
| 611 | - $this->get_string_array($key, $value[$key . "-string"], $value[$key]); | |
| 610 | +							if (array_key_exists($key."-string", $value)) { | |
| 611 | + $this->get_string_array($key, $value[$key."-string"], $value[$key]); | |
| 612 | 612 | } | 
| 613 | 613 | |
| 614 | 614 | /** | 
| 615 | 615 | ASTPP 3.0 | 
| 616 | 616 | first used,creation,expiry search date picker | 
| 617 | 617 | **/ | 
| 618 | - if ($key == 'callstart'|| | |
| 619 | - $key == 'date'|| | |
| 620 | - $key =='payment_date' || | |
| 621 | - $key == 'first_used' || | |
| 622 | - $key == 'creation' || | |
| 623 | - $key =='from_date'|| | |
| 624 | - $key =='invoice_date' || | |
| 625 | - $key =='expiry' || | |
| 626 | - $key =='created_date' || | |
| 627 | -								$key=='to_date') { | |
| 618 | + if ($key == 'callstart' || | |
| 619 | + $key == 'date' || | |
| 620 | + $key == 'payment_date' || | |
| 621 | + $key == 'first_used' || | |
| 622 | + $key == 'creation' || | |
| 623 | + $key == 'from_date' || | |
| 624 | + $key == 'invoice_date' || | |
| 625 | + $key == 'expiry' || | |
| 626 | + $key == 'created_date' || | |
| 627 | +								$key == 'to_date') { | |
| 628 | 628 | /***********************************************/ | 
| 629 | 629 | $this->get_date_array($key, $value); | 
| 630 | 630 | } | 
| @@ -641,16 +641,16 @@ discard block | ||
| 641 | 641 | |
| 642 | 642 |  	function get_date_array($field, $value) { | 
| 643 | 643 |  		if ($value != '') { | 
| 644 | -			 if (!empty($value[0])) { | |
| 645 | -				if($field == 'invoice_date'){ | |
| 646 | -					$this->db->where($field . ' >= ', gmdate("Y-m-d", strtotime($value['0']))." 00:00:01"); | |
| 647 | -					$this->db->where($field . ' <= ', gmdate("Y-m-d", strtotime($value['0']))." 23:59:59"); | |
| 648 | -				}else{ | |
| 649 | -				$this->db->where($field . ' >= ', gmdate('Y-m-d H:i:s',strtotime($value[0]))); | |
| 644 | +			 if ( ! empty($value[0])) { | |
| 645 | +				if ($field == 'invoice_date') { | |
| 646 | +					$this->db->where($field.' >= ', gmdate("Y-m-d", strtotime($value['0']))." 00:00:01"); | |
| 647 | +					$this->db->where($field.' <= ', gmdate("Y-m-d", strtotime($value['0']))." 23:59:59"); | |
| 648 | +				} else { | |
| 649 | +				$this->db->where($field.' >= ', gmdate('Y-m-d H:i:s', strtotime($value[0]))); | |
| 650 | 650 | } | 
| 651 | 651 | } | 
| 652 | -			if (!empty($value[1])) { | |
| 653 | -				$this->db->where($field . ' <= ', gmdate('Y-m-d H:i:s',strtotime($value[1]))); | |
| 652 | +			if ( ! empty($value[1])) { | |
| 653 | +				$this->db->where($field.' <= ', gmdate('Y-m-d H:i:s', strtotime($value[1]))); | |
| 654 | 654 | } | 
| 655 | 655 | } | 
| 656 | 656 | } | 
| @@ -662,19 +662,19 @@ discard block | ||
| 662 | 662 | $this->db->where($field, $search_array); | 
| 663 | 663 | break; | 
| 664 | 664 | case "2": | 
| 665 | - $this->db->where($field . ' <>', $search_array); | |
| 665 | + $this->db->where($field.' <>', $search_array); | |
| 666 | 666 | break; | 
| 667 | 667 | case "3": | 
| 668 | - $this->db->where($field . ' > ', $search_array); | |
| 668 | + $this->db->where($field.' > ', $search_array); | |
| 669 | 669 | break; | 
| 670 | 670 | case "4": | 
| 671 | - $this->db->where($field . ' < ', $search_array); | |
| 671 | + $this->db->where($field.' < ', $search_array); | |
| 672 | 672 | break; | 
| 673 | 673 | case "5": | 
| 674 | - $this->db->where($field . ' >= ', $search_array); | |
| 674 | + $this->db->where($field.' >= ', $search_array); | |
| 675 | 675 | break; | 
| 676 | 676 | case "6": | 
| 677 | - $this->db->where($field . ' <= ', $search_array); | |
| 677 | + $this->db->where($field.' <= ', $search_array); | |
| 678 | 678 | break; | 
| 679 | 679 | } | 
| 680 | 680 | } | 
| @@ -684,35 +684,35 @@ discard block | ||
| 684 | 684 |  		if ($search_array != '') { | 
| 685 | 685 |  			switch ($value) { | 
| 686 | 686 | case "1": | 
| 687 | - $str1 = $field . " LIKE '%$search_array%'"; | |
| 687 | + $str1 = $field." LIKE '%$search_array%'"; | |
| 688 | 688 | $this->db->where($str1); | 
| 689 | 689 | break; | 
| 690 | 690 | case "2": | 
| 691 | - $str1 = $field . " NOT LIKE '%$search_array%'"; | |
| 691 | + $str1 = $field." NOT LIKE '%$search_array%'"; | |
| 692 | 692 | $this->db->where($str1); | 
| 693 | 693 | break; | 
| 694 | 694 | case "3": | 
| 695 | 695 | $this->db->where($field, $search_array); | 
| 696 | 696 | break; | 
| 697 | 697 | case "4": | 
| 698 | - $this->db->where($field . ' <>', $search_array); | |
| 698 | + $this->db->where($field.' <>', $search_array); | |
| 699 | 699 | break; | 
| 700 | 700 | case "5": | 
| 701 | -					if($field == "pattern"){ | |
| 702 | - $str1 = $field . " LIKE '^".$search_array."%'"; | |
| 701 | +					if ($field == "pattern") { | |
| 702 | + $str1 = $field." LIKE '^".$search_array."%'"; | |
| 703 | 703 | $this->db->where($str1); | 
| 704 | -					} else{ | |
| 705 | - $str1 = $field . " LIKE '".$search_array."%'"; | |
| 704 | +					} else { | |
| 705 | + $str1 = $field." LIKE '".$search_array."%'"; | |
| 706 | 706 | $this->db->where($str1); | 
| 707 | 707 | } | 
| 708 | 708 | |
| 709 | 709 | break; | 
| 710 | 710 | case "6": | 
| 711 | -					if($field == "pattern"){ | |
| 712 | - $str1 = $field . " LIKE '%".$search_array.".*'"; | |
| 711 | +					if ($field == "pattern") { | |
| 712 | + $str1 = $field." LIKE '%".$search_array.".*'"; | |
| 713 | 713 | $this->db->where($str1); | 
| 714 | -					} else{ | |
| 715 | - $str1 = $field . " LIKE '%".$search_array."'"; | |
| 714 | +					} else { | |
| 715 | + $str1 = $field." LIKE '%".$search_array."'"; | |
| 716 | 716 | $this->db->where($str1); | 
| 717 | 717 | } | 
| 718 | 718 | |
| @@ -722,46 +722,46 @@ discard block | ||
| 722 | 722 | } | 
| 723 | 723 |    function build_search_string($accounts_list_search) { | 
| 724 | 724 | $where = null; | 
| 725 | - $search=$this->session->userdata($accounts_list_search); | |
| 725 | + $search = $this->session->userdata($accounts_list_search); | |
| 726 | 726 |  		if ($this->session->userdata('advance_search') == 1) { | 
| 727 | 727 | $account_search = $this->session->userdata($accounts_list_search); | 
| 728 | 728 | unset($account_search["ajax_search"]); | 
| 729 | 729 | unset($account_search["advance_search"]); | 
| 730 | -			if (!empty($account_search)) { | |
| 730 | +			if ( ! empty($account_search)) { | |
| 731 | 731 |  				foreach ($account_search as $key => $value) { | 
| 732 | 732 |  					if ($value != "") { | 
| 733 | 733 |  						if (is_array($value)) { | 
| 734 | -							if (array_key_exists($key . "-integer", $value)) { | |
| 735 | - $string=null; | |
| 736 | - $string =$this->build_interger_where($key, $value[$key . "-integer"], $value[$key]); | |
| 737 | - if($string) | |
| 738 | - $where.= "$string AND "; | |
| 734 | +							if (array_key_exists($key."-integer", $value)) { | |
| 735 | + $string = null; | |
| 736 | + $string = $this->build_interger_where($key, $value[$key."-integer"], $value[$key]); | |
| 737 | + if ($string) | |
| 738 | + $where .= "$string AND "; | |
| 739 | 739 | } | 
| 740 | -							if (array_key_exists($key . "-string", $value)) { | |
| 741 | - $string=null; | |
| 742 | - $string=$this->build_string_where($key, $value[$key . "-string"], $value[$key]); | |
| 743 | - if($string) | |
| 744 | - $where.= "$string AND "; | |
| 740 | +							if (array_key_exists($key."-string", $value)) { | |
| 741 | + $string = null; | |
| 742 | + $string = $this->build_string_where($key, $value[$key."-string"], $value[$key]); | |
| 743 | + if ($string) | |
| 744 | + $where .= "$string AND "; | |
| 745 | 745 | } | 
| 746 | -							if ($key == 'callstart'|| $key == 'date'||$key== 'log_time') { | |
| 747 | - $string=null; | |
| 748 | - $string=$this->build_date_where($key, $value); | |
| 749 | - if($string) | |
| 750 | - $where.= "$string AND "; | |
| 746 | +							if ($key == 'callstart' || $key == 'date' || $key == 'log_time') { | |
| 747 | + $string = null; | |
| 748 | + $string = $this->build_date_where($key, $value); | |
| 749 | + if ($string) | |
| 750 | + $where .= "$string AND "; | |
| 751 | 751 | } | 
| 752 | 752 |  						} else { | 
| 753 | - $where.="$key = '$value'AND "; | |
| 753 | + $where .= "$key = '$value'AND "; | |
| 754 | 754 | } | 
| 755 | 755 | } | 
| 756 | 756 | } | 
| 757 | 757 | } | 
| 758 | 758 | } | 
| 759 | - $where =rtrim($where ," AND "); | |
| 759 | + $where = rtrim($where, " AND "); | |
| 760 | 760 | return $where; | 
| 761 | 761 | } | 
| 762 | 762 | // This function using by reports module don't delete it | 
| 763 | -	function build_string_where($field, $value, $search_array){ | |
| 764 | - $where=null; | |
| 763 | +	function build_string_where($field, $value, $search_array) { | |
| 764 | + $where = null; | |
| 765 | 765 |  		 if ($search_array != '') { | 
| 766 | 766 |  			switch ($value) { | 
| 767 | 767 | case "1": | 
| @@ -777,17 +777,17 @@ discard block | ||
| 777 | 777 | $where = "$field <> '$search_array'"; | 
| 778 | 778 | break; | 
| 779 | 779 | case "5": | 
| 780 | -			if($field == "pattern"){ | |
| 781 | - $where = $field . " LIKE '^".$search_array."%'"; | |
| 782 | -			}else{ | |
| 783 | - $where = $field . " LIKE '".$search_array."%'"; | |
| 780 | +			if ($field == "pattern") { | |
| 781 | + $where = $field." LIKE '^".$search_array."%'"; | |
| 782 | +			} else { | |
| 783 | + $where = $field." LIKE '".$search_array."%'"; | |
| 784 | 784 | } | 
| 785 | 785 | break; | 
| 786 | 786 | case "6": | 
| 787 | -			if($field == "pattern"){ | |
| 788 | - $str1 = $field . " LIKE '%".$search_array.".*'"; | |
| 789 | -			}else{ | |
| 790 | - $str1 = $field . " LIKE '%".$search_array."'"; | |
| 787 | +			if ($field == "pattern") { | |
| 788 | + $str1 = $field." LIKE '%".$search_array.".*'"; | |
| 789 | +			} else { | |
| 790 | + $str1 = $field." LIKE '%".$search_array."'"; | |
| 791 | 791 | } | 
| 792 | 792 | break; | 
| 793 | 793 | } | 
| @@ -796,9 +796,9 @@ discard block | ||
| 796 | 796 | } | 
| 797 | 797 | |
| 798 | 798 |  	function build_interger_where($field, $value, $search_array) { | 
| 799 | - $where=null; | |
| 799 | + $where = null; | |
| 800 | 800 |  		if ($search_array != '') { | 
| 801 | - if(is_numeric($search_array)) | |
| 801 | + if (is_numeric($search_array)) | |
| 802 | 802 |  		{ | 
| 803 | 803 |  		switch ($value) { | 
| 804 | 804 | case "1": | 
| @@ -824,29 +824,29 @@ discard block | ||
| 824 | 824 | else | 
| 825 | 825 |  			{ | 
| 826 | 826 |  		  $this->db->where("$field IS NULL"); | 
| 827 | - $where= "$field IS NULL"; | |
| 827 | + $where = "$field IS NULL"; | |
| 828 | 828 | } | 
| 829 | 829 | } | 
| 830 | 830 | return $where; | 
| 831 | 831 | } | 
| 832 | 832 |  	function build_date_where($field, $value) { | 
| 833 | - $where =null; | |
| 833 | + $where = null; | |
| 834 | 834 |  		if ($value != '') { | 
| 835 | -			if (!empty($value[0])) { | |
| 836 | - $string=null; | |
| 837 | - $string="$field >= '$value[0]'"; | |
| 838 | - if($string) | |
| 839 | - $where.=$string." AND "; | |
| 835 | +			if ( ! empty($value[0])) { | |
| 836 | + $string = null; | |
| 837 | + $string = "$field >= '$value[0]'"; | |
| 838 | + if ($string) | |
| 839 | + $where .= $string." AND "; | |
| 840 | 840 | } | 
| 841 | -			if (!empty($value[1])) { | |
| 842 | - $string=null; | |
| 843 | - $string="$field <= '$value[1]'"; | |
| 844 | - if($string) | |
| 845 | - $where.=$string." AND "; | |
| 841 | +			if ( ! empty($value[1])) { | |
| 842 | + $string = null; | |
| 843 | + $string = "$field <= '$value[1]'"; | |
| 844 | + if ($string) | |
| 845 | + $where .= $string." AND "; | |
| 846 | 846 | } | 
| 847 | 847 | } | 
| 848 | -		if($where){ | |
| 849 | - $where =rtrim($where," AND "); | |
| 848 | +		if ($where) { | |
| 849 | + $where = rtrim($where, " AND "); | |
| 850 | 850 | } | 
| 851 | 851 | return $where; | 
| 852 | 852 | } | 
| @@ -858,10 +858,10 @@ discard block | ||
| 858 | 858 | |
| 859 | 859 |  	function update_balance($amount, $accountid, $payment_type) { | 
| 860 | 860 |  		if ($payment_type == "debit") { | 
| 861 | - $query = 'UPDATE `accounts` SET `balance` = (balance - ' . $amount . ') WHERE `id` = ' . $accountid; | |
| 861 | + $query = 'UPDATE `accounts` SET `balance` = (balance - '.$amount.') WHERE `id` = '.$accountid; | |
| 862 | 862 | return $this->db->query($query); | 
| 863 | 863 |  		} else { | 
| 864 | - $query = 'UPDATE `accounts` SET `balance` = (balance + ' . $amount . ') WHERE `id` = ' . $accountid; | |
| 864 | + $query = 'UPDATE `accounts` SET `balance` = (balance + '.$amount.') WHERE `id` = '.$accountid; | |
| 865 | 865 | return $this->db->query($query); | 
| 866 | 866 | } | 
| 867 | 867 | } | 
| @@ -875,30 +875,30 @@ discard block | ||
| 875 | 875 | // $this->db->where($field, $search_array); | 
| 876 | 876 | break; | 
| 877 | 877 | case "2": | 
| 878 | -						if($update_fields[$key] != ''){ | |
| 878 | +						if ($update_fields[$key] != '') { | |
| 879 | 879 | $updateflg = true; | 
| 880 | - $this->db->set($key,$update_fields[$key]); | |
| 880 | + $this->db->set($key, $update_fields[$key]); | |
| 881 | 881 | } | 
| 882 | 882 | break; | 
| 883 | 883 | case "3": | 
| 884 | - $this->db->set($key, $key . "+" . $update_fields[$key], FALSE); | |
| 884 | + $this->db->set($key, $key."+".$update_fields[$key], FALSE); | |
| 885 | 885 | $updateflg = true; | 
| 886 | 886 | break; | 
| 887 | 887 | case "4": | 
| 888 | - $this->db->set($key, $key . "-" . $update_fields[$key], FALSE); | |
| 888 | + $this->db->set($key, $key."-".$update_fields[$key], FALSE); | |
| 889 | 889 | $updateflg = true; | 
| 890 | 890 | break; | 
| 891 | 891 | } | 
| 892 | 892 |  			} else { | 
| 893 | -				if ($update_fields != ""){ | |
| 894 | - $this->db->set($key,$update_fields); | |
| 893 | +				if ($update_fields != "") { | |
| 894 | + $this->db->set($key, $update_fields); | |
| 895 | 895 | $updateflg = true; | 
| 896 | 896 | } | 
| 897 | 897 | } | 
| 898 | 898 | } | 
| 899 | 899 | return $updateflg; | 
| 900 | 900 | } | 
| 901 | -	function build_search_opensips($opensips_db_obj,$accounts_list_search) { | |
| 901 | +	function build_search_opensips($opensips_db_obj, $accounts_list_search) { | |
| 902 | 902 |  		if ($this->session->userdata('advance_search') == 1) { | 
| 903 | 903 | $account_search = $this->session->userdata($accounts_list_search); | 
| 904 | 904 | unset($account_search["ajax_search"]); | 
| @@ -906,11 +906,11 @@ discard block | ||
| 906 | 906 |  			foreach ($account_search as $key => $value) { | 
| 907 | 907 |  				if ($value != "") { | 
| 908 | 908 |  					if (is_array($value)) { | 
| 909 | -						if (array_key_exists($key . "-integer", $value)) { | |
| 910 | - $this->get_opensips_interger_array($opensips_db_obj,$key, $value[$key . "-integer"], $value[$key]); | |
| 909 | +						if (array_key_exists($key."-integer", $value)) { | |
| 910 | + $this->get_opensips_interger_array($opensips_db_obj, $key, $value[$key."-integer"], $value[$key]); | |
| 911 | 911 | } | 
| 912 | -						if (array_key_exists($key . "-string", $value)) { | |
| 913 | - $this->get_opensips_string_array($opensips_db_obj,$key, $value[$key . "-string"], $value[$key]); | |
| 912 | +						if (array_key_exists($key."-string", $value)) { | |
| 913 | + $this->get_opensips_string_array($opensips_db_obj, $key, $value[$key."-string"], $value[$key]); | |
| 914 | 914 | } | 
| 915 | 915 |  					} else { | 
| 916 | 916 | $opensips_db_obj->where($key, $value); | 
| @@ -920,32 +920,32 @@ discard block | ||
| 920 | 920 | } | 
| 921 | 921 | } | 
| 922 | 922 | |
| 923 | -	function get_opensips_interger_array($opensips_db_obj,$field, $value, $search_array) { | |
| 923 | +	function get_opensips_interger_array($opensips_db_obj, $field, $value, $search_array) { | |
| 924 | 924 |  		if ($search_array != '') { | 
| 925 | 925 |  			switch ($value) { | 
| 926 | 926 | case "1": | 
| 927 | 927 | $opensips_db_obj->where($field, $search_array); | 
| 928 | 928 | break; | 
| 929 | 929 | case "2": | 
| 930 | - $opensips_db_obj->where($field . ' <>', $search_array); | |
| 930 | + $opensips_db_obj->where($field.' <>', $search_array); | |
| 931 | 931 | break; | 
| 932 | 932 | case "3": | 
| 933 | - $opensips_db_obj->where($field . ' > ', $search_array); | |
| 933 | + $opensips_db_obj->where($field.' > ', $search_array); | |
| 934 | 934 | break; | 
| 935 | 935 | case "4": | 
| 936 | - $opensips_db_obj->where($field . ' < ', $search_array); | |
| 936 | + $opensips_db_obj->where($field.' < ', $search_array); | |
| 937 | 937 | break; | 
| 938 | 938 | case "5": | 
| 939 | - $opensips_db_obj->where($field . ' >= ', $search_array); | |
| 939 | + $opensips_db_obj->where($field.' >= ', $search_array); | |
| 940 | 940 | break; | 
| 941 | 941 | case "6": | 
| 942 | - $opensips_db_obj->where($field . ' <= ', $search_array); | |
| 942 | + $opensips_db_obj->where($field.' <= ', $search_array); | |
| 943 | 943 | break; | 
| 944 | 944 | } | 
| 945 | 945 | } | 
| 946 | 946 | } | 
| 947 | 947 | |
| 948 | -	function get_opensips_string_array($opensips_db_obj,$field, $value, $search_array) { | |
| 948 | +	function get_opensips_string_array($opensips_db_obj, $field, $value, $search_array) { | |
| 949 | 949 |  		if ($search_array != '') { | 
| 950 | 950 |  			switch ($value) { | 
| 951 | 951 | case "1": | 
| @@ -958,14 +958,14 @@ discard block | ||
| 958 | 958 | $opensips_db_obj->where($field, $search_array); | 
| 959 | 959 | break; | 
| 960 | 960 | case "4": | 
| 961 | - $opensips_db_obj->where($field . ' <>', $search_array); | |
| 961 | + $opensips_db_obj->where($field.' <>', $search_array); | |
| 962 | 962 | break; | 
| 963 | 963 | case "5": | 
| 964 | - $str1 = $field . " LIKE '".$search_array."%'"; | |
| 964 | + $str1 = $field." LIKE '".$search_array."%'"; | |
| 965 | 965 | $opensips_db_obj->where($str1); | 
| 966 | 966 | break; | 
| 967 | 967 | case "6": | 
| 968 | - $str1 = $field . " LIKE '%".$search_array."'"; | |
| 968 | + $str1 = $field." LIKE '%".$search_array."'"; | |
| 969 | 969 | $opensips_db_obj->where($str1); | 
| 970 | 970 | break; | 
| 971 | 971 | } | 
| @@ -980,7 +980,7 @@ discard block | ||
| 980 | 980 |  		} else { | 
| 981 | 981 |  			$cnt_str = " $select_params[1],' (',$select_params[2],')' "; | 
| 982 | 982 | } | 
| 983 | - $select = $select_params[0] . ", concat($cnt_str) as $select_params[1] ,".$select_params[4] ; | |
| 983 | + $select = $select_params[0].", concat($cnt_str) as $select_params[1] ,".$select_params[4]; | |
| 984 | 984 |  		$logintype = $this->session->userdata('logintype'); | 
| 985 | 985 |  		if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr') { | 
| 986 | 986 |  			$account_data = $this->session->userdata("accountinfo"); | 
| @@ -991,12 +991,12 @@ discard block | ||
| 991 | 991 | $drp_array = $drp_array->result(); | 
| 992 | 992 | $drp_list = array(); | 
| 993 | 993 |  		foreach ($drp_array as $drp_value) { | 
| 994 | - if($drp_value->type == 3) | |
| 994 | + if ($drp_value->type == 3) | |
| 995 | 995 |  			{ | 
| 996 | 996 | $drp_list['Provider'][$drp_value->id] = $drp_value->first_name; | 
| 997 | -			}elseif($drp_value->type == 1){ | |
| 997 | +			}elseif ($drp_value->type == 1) { | |
| 998 | 998 | $drp_list['Reseller'][$drp_value->id] = $drp_value->first_name; | 
| 999 | -			}else{ | |
| 999 | +			} else { | |
| 1000 | 1000 | $drp_list['Customer'][$drp_value->id] = $drp_value->first_name; | 
| 1001 | 1001 | } | 
| 1002 | 1002 | } | 
| @@ -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 | 
| @@ -56,8 +56,8 @@ discard block | ||
| 56 | 56 | $config = array(); | 
| 57 | 57 | $result = $query->result_array(); | 
| 58 | 58 |  		foreach ($result as $row) { | 
| 59 | -			if($row['name'] == 'decimal_points' || $row['name'] == 'starting_digit' || $row['name'] == 'card_length' || $row['name'] == 'pin_length'){ | |
| 60 | -				$row['name'] = str_replace("_","",$row['name']); | |
| 59 | +			if ($row['name'] == 'decimal_points' || $row['name'] == 'starting_digit' || $row['name'] == 'card_length' || $row['name'] == 'pin_length') { | |
| 60 | +				$row['name'] = str_replace("_", "", $row['name']); | |
| 61 | 61 | } | 
| 62 | 62 | $config[$row['name']] = $row['value']; | 
| 63 | 63 | } | 
| @@ -87,9 +87,9 @@ discard block | ||
| 87 | 87 | return $currencylist; | 
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | -	function get_admin_info(){ | |
| 91 | -		 $result=$this->db->get_where('accounts',array('type'=>'-1')); | |
| 92 | - $result=$result->result_array(); | |
| 90 | +	function get_admin_info() { | |
| 91 | +		 $result = $this->db->get_where('accounts', array('type'=>'-1')); | |
| 92 | + $result = $result->result_array(); | |
| 93 | 93 | self::$global_config['admin_info'] = $result[0]; | 
| 94 | 94 | return $result[0]; | 
| 95 | 95 | } | 
| @@ -97,7 +97,7 @@ discard block | ||
| 97 | 97 | * Changes for invoices | 
| 98 | 98 | */ | 
| 99 | 99 |  	 function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) { | 
| 100 | - $amount = str_replace( ',', '', $amount ); | |
| 100 | +		$amount = str_replace(',', '', $amount); | |
| 101 | 101 |  		$invoice_data = array("accountid" => $accountid, | 
| 102 | 102 | "invoice_prefix" => $invoice_prefix, | 
| 103 | 103 | "invoiceid" => $last_invoice_ID, | 
| @@ -123,16 +123,16 @@ discard block | ||
| 123 | 123 | $to_currency1 = $this->session->userdata['accountinfo']['currency_id']; | 
| 124 | 124 |  				$to_currency = $this->common->get_field_name('currency', 'currency', $to_currency1); | 
| 125 | 125 | } | 
| 126 | - $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0)?self::$global_config['currency_list'][$from_currency]:1; | |
| 127 | - $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; | |
| 128 | - $amount = str_replace( ',', '', $amount ); | |
| 126 | + $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0) ? self::$global_config['currency_list'][$from_currency] : 1; | |
| 127 | + $to_cur_rate = (self::$global_config['currency_list'][$to_currency]) ? self::$global_config['currency_list'][$to_currency] : 1; | |
| 128 | +		$amount = str_replace(',', '', $amount); | |
| 129 | 129 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; | 
| 130 | 130 | if ($format_currency) | 
| 131 | 131 | $cal_amount = $this->format_currency($cal_amount); | 
| 132 | -		if ($append_currency){ | |
| 133 | - $cal_amount = $cal_amount . " " . $to_currency; | |
| 132 | +		if ($append_currency) { | |
| 133 | + $cal_amount = $cal_amount." ".$to_currency; | |
| 134 | 134 | } | 
| 135 | - $cal_amount = str_replace( ',', '', $cal_amount ); | |
| 135 | +		$cal_amount = str_replace(',', '', $cal_amount); | |
| 136 | 136 | return $cal_amount; | 
| 137 | 137 | } | 
| 138 | 138 |  	function calculate_currency_customer($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { | 
| @@ -142,35 +142,35 @@ discard block | ||
| 142 | 142 | $to_currency1 = $this->session->userdata['accountinfo']['currency_id']; | 
| 143 | 143 |  				$to_currency = $this->common->get_field_name('currency', 'currency', $to_currency1); | 
| 144 | 144 | } | 
| 145 | - $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0)?self::$global_config['currency_list'][$from_currency]:1; | |
| 146 | - $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; | |
| 147 | - $amount = str_replace( ',', '', $amount ); | |
| 145 | + $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0) ? self::$global_config['currency_list'][$from_currency] : 1; | |
| 146 | + $to_cur_rate = (self::$global_config['currency_list'][$to_currency]) ? self::$global_config['currency_list'][$to_currency] : 1; | |
| 147 | +		$amount = str_replace(',', '', $amount); | |
| 148 | 148 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; | 
| 149 | 149 | if ($format_currency) | 
| 150 | 150 | $cal_amount = $this->format_currency($cal_amount); | 
| 151 | 151 | if ($append_currency) | 
| 152 | - $cal_amount = $cal_amount ; | |
| 153 | - $cal_amount = str_replace( ',', '', $cal_amount ); | |
| 152 | + $cal_amount = $cal_amount; | |
| 153 | +		$cal_amount = str_replace(',', '', $cal_amount); | |
| 154 | 154 | return $cal_amount; | 
| 155 | 155 | } | 
| 156 | 156 | |
| 157 | 157 |  	function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { | 
| 158 | - $amount = str_replace( ',', '', $amount ); | |
| 158 | +		$amount = str_replace(',', '', $amount); | |
| 159 | 159 |  		if ($from_currency == '') { | 
| 160 | 160 | $from_currency1 = $this->session->userdata['accountinfo']['currency_id']; | 
| 161 | 161 |  				$from_currency = $this->common->get_field_name('currency', 'currency', $from_currency1); | 
| 162 | 162 | } | 
| 163 | 163 | $to_currency = ($to_currency == '') ? self::$global_config['system_config']['base_currency'] : $to_currency; | 
| 164 | -		if(self::$global_config['currency_list'][$from_currency] > 0){ | |
| 164 | +		if (self::$global_config['currency_list'][$from_currency] > 0) { | |
| 165 | 165 | $cal_amount = ($amount * self::$global_config['currency_list'][$to_currency]) / self::$global_config['currency_list'][$from_currency]; | 
| 166 | -		}else{ | |
| 167 | - $cal_amount=$amount; | |
| 166 | +		} else { | |
| 167 | + $cal_amount = $amount; | |
| 168 | 168 | } | 
| 169 | 169 | if ($format_currency) | 
| 170 | 170 | $cal_amount = $this->format_currency($cal_amount); | 
| 171 | 171 | if ($append_currency) | 
| 172 | - $cal_amount = $cal_amount . " " . $to_currency; | |
| 173 | - $cal_amount = str_replace( ',', '', $cal_amount ); | |
| 172 | + $cal_amount = $cal_amount." ".$to_currency; | |
| 173 | +		$cal_amount = str_replace(',', '', $cal_amount); | |
| 174 | 174 | return $cal_amount; | 
| 175 | 175 | } | 
| 176 | 176 | |
| @@ -181,26 +181,26 @@ discard block | ||
| 181 | 181 | } | 
| 182 | 182 | $from_currency = ($from_currency == '') ? self::$global_config['system_config']['base_currency'] : $from_currency; | 
| 183 | 183 | |
| 184 | - $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0)?self::$global_config['currency_list'][$from_currency]:1; | |
| 185 | - $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; | |
| 186 | - $amount = str_replace( ',', '', $amount ); | |
| 184 | + $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0) ? self::$global_config['currency_list'][$from_currency] : 1; | |
| 185 | + $to_cur_rate = (self::$global_config['currency_list'][$to_currency]) ? self::$global_config['currency_list'][$to_currency] : 1; | |
| 186 | +		$amount = str_replace(',', '', $amount); | |
| 187 | 187 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; | 
| 188 | 188 | if ($format_currency) | 
| 189 | 189 | $cal_amount = $this->format_currency($cal_amount); | 
| 190 | 190 | if ($append_currency) | 
| 191 | - $cal_amount = $cal_amount . " " . $to_currency; | |
| 192 | - $cal_amount = str_replace( ',', '', $cal_amount ); | |
| 191 | + $cal_amount = $cal_amount." ".$to_currency; | |
| 192 | +		$cal_amount = str_replace(',', '', $cal_amount); | |
| 193 | 193 | return $cal_amount; | 
| 194 | 194 | } | 
| 195 | 195 | |
| 196 | 196 |  	function format_currency($amount) { | 
| 197 | - $amount = str_replace( ',', '', $amount ); | |
| 198 | - return number_format($amount,Common_model::$global_config['system_config']['decimalpoints']); | |
| 197 | +		$amount = str_replace(',', '', $amount); | |
| 198 | + return number_format($amount, Common_model::$global_config['system_config']['decimalpoints']); | |
| 199 | 199 | // return $amount; | 
| 200 | 200 | } | 
| 201 | 201 | |
| 202 | 202 |  	function money_format($format, $number) { | 
| 203 | - $regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?' . | |
| 203 | + $regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?'. | |
| 204 | 204 | '(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/'; | 
| 205 | 205 |  		if (setlocale(LC_MONETARY, 0) == 'C') { | 
| 206 | 206 | setlocale(LC_MONETARY, ''); | 
| @@ -218,9 +218,9 @@ discard block | ||
| 218 | 218 |  				'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, | 
| 219 | 219 |  				'isleft' => preg_match('/\-/', $fmatch[1]) > 0 | 
| 220 | 220 | ); | 
| 221 | - $width = trim($fmatch[2]) ? (int) $fmatch[2] : 0; | |
| 222 | - $left = trim($fmatch[3]) ? (int) $fmatch[3] : 0; | |
| 223 | - $right = trim($fmatch[4]) ? (int) $fmatch[4] : $locale['int_frac_digits']; | |
| 221 | + $width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; | |
| 222 | + $left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; | |
| 223 | + $right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; | |
| 224 | 224 | $conversion = $fmatch[5]; | 
| 225 | 225 | |
| 226 | 226 | $positive = true; | 
| @@ -252,9 +252,9 @@ discard block | ||
| 252 | 252 | $suffix = ')'; | 
| 253 | 253 | break; | 
| 254 | 254 | } | 
| 255 | -			if (!$flags['nosimbol']) { | |
| 256 | - $currency = $cprefix . | |
| 257 | - ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']) . | |
| 255 | +			if ( ! $flags['nosimbol']) { | |
| 256 | + $currency = $cprefix. | |
| 257 | + ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']). | |
| 258 | 258 | $csuffix; | 
| 259 | 259 |  			} else { | 
| 260 | 260 | $currency = ''; | 
| @@ -266,13 +266,13 @@ discard block | ||
| 266 | 266 | |
| 267 | 267 | $n = strlen($prefix) + strlen($currency) + strlen($value[0]); | 
| 268 | 268 |  			if ($left > 0 && $left > $n) { | 
| 269 | - $value[0] = str_repeat($flags['fillchar'], $left - $n) . $value[0]; | |
| 269 | + $value[0] = str_repeat($flags['fillchar'], $left - $n).$value[0]; | |
| 270 | 270 | } | 
| 271 | 271 | $value = implode($locale['mon_decimal_point'], $value); | 
| 272 | 272 |  			if ($locale["{$letter}_cs_precedes"]) { | 
| 273 | - $value = $prefix . $currency . $space . $value . $suffix; | |
| 273 | + $value = $prefix.$currency.$space.$value.$suffix; | |
| 274 | 274 |  			} else { | 
| 275 | - $value = $prefix . $value . $space . $currency . $suffix; | |
| 275 | + $value = $prefix.$value.$space.$currency.$suffix; | |
| 276 | 276 | } | 
| 277 | 277 |  			if ($width > 0) { | 
| 278 | 278 | $value = str_pad($value, $width, $flags['fillchar'], $flags['isleft'] ? | 
| @@ -311,14 +311,14 @@ discard block | ||
| 311 | 311 | /* ASTPP 3.0 | 
| 312 | 312 | * Using for Payment Functionality from Admin/Reseller Login | 
| 313 | 313 | */ | 
| 314 | -	function get_parent_info($accountid){ | |
| 315 | -		$this->db->where('id',$accountid); | |
| 314 | +	function get_parent_info($accountid) { | |
| 315 | +		$this->db->where('id', $accountid); | |
| 316 | 316 |  		$this->db->select('reseller_id,type'); | 
| 317 | -		$account_result=$this->db->get('accounts'); | |
| 318 | - $account_result=(array)$account_result->first_row(); | |
| 319 | -		if(isset($account_result['reseller_id']) && $account_result['reseller_id']> 0){ | |
| 317 | +		$account_result = $this->db->get('accounts'); | |
| 318 | + $account_result = (array)$account_result->first_row(); | |
| 319 | +		if (isset($account_result['reseller_id']) && $account_result['reseller_id'] > 0) { | |
| 320 | 320 | return $account_result['reseller_id']; | 
| 321 | -		}else{ | |
| 321 | +		} else { | |
| 322 | 322 | return '0'; | 
| 323 | 323 | } | 
| 324 | 324 | |
| @@ -341,7 +341,7 @@ discard block | ||
| 341 | 341 | $query = $query->result_array(); | 
| 342 | 342 | $sub_total = $query["0"]["total"]; | 
| 343 | 343 | } | 
| 344 | - $tax_total = (($sub_total * ( $tax_value['taxes_rate'] / 100 )) + $tax_value['taxes_amount'] ); | |
| 344 | + $tax_total = (($sub_total * ($tax_value['taxes_rate'] / 100)) + $tax_value['taxes_amount']); | |
| 345 | 345 | $tax_total = round($tax_total, self::$global_config['system_config']['decimalpoints']); | 
| 346 | 346 |  					$tax_array = array("accountid" => $account['id'], "reseller_id" => $account['reseller_id'], "invoiceid" => $invoiceid, "item_id" => "0", "description" => $tax_value['taxes_description'], "debit" => $tax_total, "credit" => "", "item_type" => "TAX", "created_date" => $start_date); | 
| 347 | 347 |  					$this->db->insert("invoice_details", $tax_array); | 
| @@ -31,11 +31,11 @@ | ||
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 | |
| 34 | -	function customer_list_status($id){ | |
| 34 | +	function customer_list_status($id) { | |
| 35 | 35 | $post_data = $this->input->post(); | 
| 36 | - $post_data['table']=$this->common->decode($post_data['table']); | |
| 37 | - $data['status']=$post_data['status'] =='true'? 0:1; | |
| 38 | -			 $result=$post_data['table'] =='accounts' && $post_data['id'] == 1 ? null:$this->db->update($post_data['table'],$data,array("id"=>$post_data['id'])); | |
| 36 | + $post_data['table'] = $this->common->decode($post_data['table']); | |
| 37 | + $data['status'] = $post_data['status'] == 'true' ? 0 : 1; | |
| 38 | +			 $result = $post_data['table'] == 'accounts' && $post_data['id'] == 1 ? null : $this->db->update($post_data['table'], $data, array("id"=>$post_data['id'])); | |
| 39 | 39 | echo TRUE; | 
| 40 | 40 | } | 
| 41 | 41 | |
| @@ -25,19 +25,19 @@ | ||
| 25 | 25 | function __construct() | 
| 26 | 26 |  	{ | 
| 27 | 27 | parent::__construct(); | 
| 28 | - if(!defined( 'CRON' ) ) | |
| 28 | +	if ( ! defined('CRON'))   | |
| 29 | 29 | exit(); | 
| 30 | 30 |  		$this->load->model("db_model"); | 
| 31 | 31 |  		$this->load->library("astpp/common"); | 
| 32 | 32 | } | 
| 33 | -	function low_creditlimit(){ | |
| 34 | -		$where = array("posttoexternal"=>1,"deleted" => "0","status"=>"0"); | |
| 33 | +	function low_creditlimit() { | |
| 34 | +		$where = array("posttoexternal"=>1, "deleted" => "0", "status"=>"0"); | |
| 35 | 35 |  		$query = $this->db_model->getSelect("*", "accounts", $where); | 
| 36 | -		if($query->num_rows >0){ | |
| 36 | +		if ($query->num_rows > 0) { | |
| 37 | 37 | $account_data = $query->result_array(); | 
| 38 | -			foreach($account_data as $data_key =>$account_value){ | |
| 39 | -				if(($account_value["balance"]) >= $account_value["credit_limit"]){ | |
| 40 | -				  $this->common->mail_to_users("email_low_balance",$account_value);    | |
| 38 | +			foreach ($account_data as $data_key =>$account_value) { | |
| 39 | +				if (($account_value["balance"]) >= $account_value["credit_limit"]) { | |
| 40 | +				  $this->common->mail_to_users("email_low_balance", $account_value);    | |
| 41 | 41 | } | 
| 42 | 42 | } | 
| 43 | 43 | } | 
| @@ -25,19 +25,19 @@ | ||
| 25 | 25 | function __construct() | 
| 26 | 26 |  	{ | 
| 27 | 27 | parent::__construct(); | 
| 28 | - if(!defined( 'CRON' ) ) | |
| 28 | +	if ( ! defined('CRON'))   | |
| 29 | 29 | exit(); | 
| 30 | 30 |  		$this->load->model("db_model"); | 
| 31 | 31 |  		$this->load->library("astpp/common"); | 
| 32 | 32 | } | 
| 33 | -	function low_balance(){ | |
| 34 | -		$where = array("posttoexternal"=>0,"notify_flag"=>0,"deleted" => "0","status"=>"0"); | |
| 33 | +	function low_balance() { | |
| 34 | +		$where = array("posttoexternal"=>0, "notify_flag"=>0, "deleted" => "0", "status"=>"0"); | |
| 35 | 35 |  		$query = $this->db_model->getSelect("*", "accounts", $where); | 
| 36 | -		if($query->num_rows >0){ | |
| 36 | +		if ($query->num_rows > 0) { | |
| 37 | 37 | $account_data = $query->result_array(); | 
| 38 | -			foreach($account_data as $data_key =>$accountinfo){ | |
| 39 | -				if(($accountinfo["balance"]) <= $accountinfo["notify_credit_limit"]){ | |
| 40 | -				  $this->common->mail_to_users("email_low_balance",$accountinfo);    | |
| 38 | +			foreach ($account_data as $data_key =>$accountinfo) { | |
| 39 | +				if (($accountinfo["balance"]) <= $accountinfo["notify_credit_limit"]) { | |
| 40 | +				  $this->common->mail_to_users("email_low_balance", $accountinfo);    | |
| 41 | 41 | } | 
| 42 | 42 | } | 
| 43 | 43 | } | 
| @@ -31,83 +31,83 @@ | ||
| 31 | 31 |  		$this->load->model('db_model'); | 
| 32 | 32 |  		$this->load->model('Astpp_common'); | 
| 33 | 33 | } | 
| 34 | -	function index($sipnumber=''){ | |
| 35 | - $opensips_flag=common_model::$global_config['system_config']['opensips']; | |
| 36 | - $accountid_arr=0; | |
| 37 | - 	if($opensips_flag == '1'){ | |
| 38 | -			$where=array('username'=>$sipnumber); | |
| 39 | -			$accountid_arr=$this->db_model->getSelect('accountid','sip_devices',$where); | |
| 34 | +	function index($sipnumber = '') { | |
| 35 | + $opensips_flag = common_model::$global_config['system_config']['opensips']; | |
| 36 | + $accountid_arr = 0; | |
| 37 | + 	if ($opensips_flag == '1') { | |
| 38 | +			$where = array('username'=>$sipnumber); | |
| 39 | +			$accountid_arr = $this->db_model->getSelect('accountid', 'sip_devices', $where); | |
| 40 | 40 | } | 
| 41 | -	else{ | |
| 41 | +	else { | |
| 42 | 42 | $db_config = Common_model::$global_config['system_config']; | 
| 43 | - $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="; | |
| 43 | + $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 | 44 | $this->opensips_db = $this->load->database($opensipdsn, true); | 
| 45 | 45 |  		$this->opensips_db->where(array("username"=>$sipnumber)); | 
| 46 | -		$accountnum_arr=$this->opensips_db->get("subscriber"); | |
| 47 | - $accountnum_arr=$accountnum_arr->result_array(); | |
| 48 | -		foreach($accountnum_arr as $value_num){ | |
| 49 | -		$accountid_arr = $this->db_model->getSelect('id','accounts',array('number'=>$value_num['accountcode'])); | |
| 46 | +		$accountnum_arr = $this->opensips_db->get("subscriber"); | |
| 47 | + $accountnum_arr = $accountnum_arr->result_array(); | |
| 48 | +		foreach ($accountnum_arr as $value_num) { | |
| 49 | +		$accountid_arr = $this->db_model->getSelect('id', 'accounts', array('number'=>$value_num['accountcode'])); | |
| 50 | 50 | } | 
| 51 | 51 | } | 
| 52 | -	if($accountid_arr == ''){ | |
| 52 | +	if ($accountid_arr == '') { | |
| 53 | 53 | echo "Please enter proper username of SIP Account"; | 
| 54 | 54 | } | 
| 55 | -	if($accountid_arr->num_rows()==0 ){ | |
| 56 | -		$where=array('number'=>$sipnumber); | |
| 57 | -		$accountid_arr=$this->db_model->getSelect('id','accounts',$where); | |
| 55 | +	if ($accountid_arr->num_rows() == 0) { | |
| 56 | +		$where = array('number'=>$sipnumber); | |
| 57 | +		$accountid_arr = $this->db_model->getSelect('id', 'accounts', $where); | |
| 58 | 58 | } | 
| 59 | -	if($accountid_arr->num_rows()>0){ | |
| 60 | - $accountid_arr=$accountid_arr->result_array(); | |
| 61 | -		if($opensips_flag == '1'){ | |
| 62 | -		   foreach($accountid_arr[0] as $key=>$value){ | |
| 59 | +	if ($accountid_arr->num_rows() > 0) { | |
| 60 | + $accountid_arr = $accountid_arr->result_array(); | |
| 61 | +		if ($opensips_flag == '1') { | |
| 62 | +		   foreach ($accountid_arr[0] as $key=>$value) { | |
| 63 | 63 | } | 
| 64 | -		  if($key== 'id'){ | |
| 65 | - $accountid=$accountid_arr[0]['id']; | |
| 66 | -		  } else{ | |
| 67 | - $accountid=$accountid_arr[0]['accountid']; | |
| 64 | +		  if ($key == 'id') { | |
| 65 | + $accountid = $accountid_arr[0]['id']; | |
| 66 | +		  } else { | |
| 67 | + $accountid = $accountid_arr[0]['accountid']; | |
| 68 | 68 | } | 
| 69 | -		} else{ | |
| 70 | - $accountid=$accountid_arr[0]['id']; | |
| 69 | +		} else { | |
| 70 | + $accountid = $accountid_arr[0]['id']; | |
| 71 | 71 | } | 
| 72 | 72 | $to_currency = common_model::$global_config['system_config']['base_currency']; | 
| 73 | -		if($accountid > 0){ | |
| 74 | -		$where=array('id'=>$accountid); | |
| 75 | -		$balance=$this->db_model->getSelect('balance,currency_id','accounts',$where); | |
| 76 | -			if($balance->num_rows() > 0){ | |
| 73 | +		if ($accountid > 0) { | |
| 74 | +		$where = array('id'=>$accountid); | |
| 75 | +		$balance = $this->db_model->getSelect('balance,currency_id', 'accounts', $where); | |
| 76 | +			if ($balance->num_rows() > 0) { | |
| 77 | 77 | //get balance,currency using by user from account number. | 
| 78 | 78 | $balance_arr = $balance->result_array(); | 
| 79 | - $balance=$balance_arr['0']['balance']; | |
| 80 | - $currency=$balance_arr['0']['currency_id']; | |
| 79 | + $balance = $balance_arr['0']['balance']; | |
| 80 | + $currency = $balance_arr['0']['currency_id']; | |
| 81 | 81 | //Get Base Currency From System which is main currency of system. | 
| 82 | -				$base_currency_arr=$this->db_model->getSelect('value','system',array('name'=>'base_currency')); | |
| 83 | - $base_currency_arr=$base_currency_arr->result_array(); | |
| 84 | - $base_currency=$base_currency_arr['0']['value']; | |
| 82 | +				$base_currency_arr = $this->db_model->getSelect('value', 'system', array('name'=>'base_currency')); | |
| 83 | + $base_currency_arr = $base_currency_arr->result_array(); | |
| 84 | + $base_currency = $base_currency_arr['0']['value']; | |
| 85 | 85 | //Get basse Currency rate from Currency Name. | 
| 86 | -				$base_currency_info=$this->db_model->getSelect('*','currency',array('currency'=>$base_currency)); | |
| 87 | - $base_currency_info=$base_currency_info->result_array(); | |
| 88 | - $base_currency_rate=$base_currency_info['0']['currencyrate']; | |
| 89 | - $base_currency_name=$base_currency_info['0']['currency']; | |
| 86 | +				$base_currency_info = $this->db_model->getSelect('*', 'currency', array('currency'=>$base_currency)); | |
| 87 | + $base_currency_info = $base_currency_info->result_array(); | |
| 88 | + $base_currency_rate = $base_currency_info['0']['currencyrate']; | |
| 89 | + $base_currency_name = $base_currency_info['0']['currency']; | |
| 90 | 90 | //Find Currency Rate of user Currency from its currency_id | 
| 91 | -				$where= array('id'=>$currency); | |
| 92 | -				$user_currency_info=$this->db_model->getSelect("*",'currency',$where); | |
| 91 | +				$where = array('id'=>$currency); | |
| 92 | +				$user_currency_info = $this->db_model->getSelect("*", 'currency', $where); | |
| 93 | 93 | //user Currency Is deleted or Not | 
| 94 | -				if($user_currency_info->num_rows() > 0){ | |
| 95 | - $user_currency_info=$user_currency_info->result_array(); | |
| 96 | - $user_currency=$user_currency_info['0']['currencyrate']; | |
| 97 | - $user_currency_name=$user_currency_info['0']['currency']; | |
| 98 | -				} else{ | |
| 99 | - $user_currency=$base_currency_rate; | |
| 100 | - $user_currency_name=$base_currency_name; | |
| 94 | +				if ($user_currency_info->num_rows() > 0) { | |
| 95 | + $user_currency_info = $user_currency_info->result_array(); | |
| 96 | + $user_currency = $user_currency_info['0']['currencyrate']; | |
| 97 | + $user_currency_name = $user_currency_info['0']['currency']; | |
| 98 | +				} else { | |
| 99 | + $user_currency = $base_currency_rate; | |
| 100 | + $user_currency_name = $base_currency_name; | |
| 101 | 101 | } | 
| 102 | 102 | // Convert Balance of user in user currency | 
| 103 | - $convert_balance=round(($balance * $user_currency)/$base_currency_rate,2); | |
| 104 | -				$convert_balance=sprintf("%.2f", $convert_balance).' '.$user_currency_name; | |
| 103 | + $convert_balance = round(($balance * $user_currency) / $base_currency_rate, 2); | |
| 104 | +				$convert_balance = sprintf("%.2f", $convert_balance).' '.$user_currency_name; | |
| 105 | 105 | echo "Balance : ".$convert_balance; | 
| 106 | 106 | } | 
| 107 | -		} else{ | |
| 107 | +		} else { | |
| 108 | 108 | echo "0.00 ".$to_currency; | 
| 109 | 109 | } | 
| 110 | -	} else{ | |
| 110 | +	} else { | |
| 111 | 111 | echo "Please enter proper username of SIP Account"; | 
| 112 | 112 | } | 
| 113 | 113 | } |