Completed
Pull Request — v3.0 (#136)
by
unknown
25:07
created
web_interface/astpp/application/controllers/currencyupdate.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,30 +29,30 @@  discard block
 block discarded – undo
29 29
         $this->load->model("db_model");
30 30
         $this->load->library("astpp/common");
31 31
     }
32
-    function update_currency(){
32
+    function update_currency() {
33 33
         $where = array("currency <>"=> Common_model::$global_config['system_config']['base_currency']);
34 34
         $query = $this->db_model->getSelect("*", "currency", $where);
35 35
 
36
-        if($query->num_rows >0){
37
-            $currency_data =$query->result_array();
36
+        if ($query->num_rows > 0) {
37
+            $currency_data = $query->result_array();
38 38
     		$url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=";
39 39
 	    	foreach ($currency_data as $currency_value) {
40 40
 	    	    $url .= Common_model::$global_config['system_config']['base_currency'].$currency_value['currency'].'=X+';
41 41
 	    	}
42 42
 	    	$url .= '&f=l1';
43 43
 
44
-	    	$sql='';
44
+	    	$sql = '';
45 45
 	    	$response = $this->curl_response($url);
46
-	    	$content_data = explode(' ',$response);
46
+	    	$content_data = explode(' ', $response);
47 47
 
48
-	    	foreach ($content_data as $content_data1){
49
-	    	   $currency_arr= explode("\n", $content_data1);
50
-	    	    foreach($currency_arr as $final_val)
48
+	    	foreach ($content_data as $content_data1) {
49
+	    	   $currency_arr = explode("\n", $content_data1);
50
+	    	    foreach ($currency_arr as $final_val)
51 51
 	    	    {
52 52
 	    	        $currency_final = array();
53
-	    		    $currency_final= explode(',', $final_val);
54
-	    		    if(isset($currency_final[1]) && $currency_final[1] != "" && $currency_final[0]!='' && $currency_final[1] != 'N/A'){
55
-			      $sql = "UPDATE currency SET currencyRate = ".$currency_final[1]." WHERE currency = '".substr($currency_final[0],4,3)."'";
53
+	    		    $currency_final = explode(',', $final_val);
54
+	    		    if (isset($currency_final[1]) && $currency_final[1] != "" && $currency_final[0] != '' && $currency_final[1] != 'N/A') {
55
+			      $sql = "UPDATE currency SET currencyRate = ".$currency_final[1]." WHERE currency = '".substr($currency_final[0], 4, 3)."'";
56 56
 			      $this->db->query($sql);
57 57
 	    		    }
58 58
 	    	    }
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 	function curl_response($url)
68 68
 	{
69
-		    $ch = curl_init();  // Initialising cURL
70
-		    curl_setopt ( $ch, CURLOPT_URL, $url );
71
-		    curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
72
-		    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
73
-		    curl_setopt ( $ch, CURLOPT_ENCODING, "" );
74
-		    curl_setopt ( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)" );
69
+		    $ch = curl_init(); // Initialising cURL
70
+		    curl_setopt($ch, CURLOPT_URL, $url);
71
+		    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
72
+		    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
73
+		    curl_setopt($ch, CURLOPT_ENCODING, "");
74
+		    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
75 75
 		    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
76
-		    curl_close($ch);        // Closing cURL
76
+		    curl_close($ch); // Closing cURL
77 77
 		    return $data;
78 78
 	}
79 79
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/lowbalance.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,19 +25,19 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
web_interface/astpp/application/errors/error_404.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 	<div id="container">
58 58
 		<h1><?php echo $heading; ?></h1>
59 59
 		<?php echo $message; ?>
60
-		<? Header("Location: /dashboard/");?>
60
+		<? Header("Location: /dashboard/"); ?>
61 61
 	</div>
62 62
 </body>
63 63
 </html>
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/Timezone.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,22 +22,22 @@  discard block
 block discarded – undo
22 22
 ###############################################################################
23 23
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
24 24
 class Timezone {
25
-  function __construct(){
26
-	$this->CI =& get_instance();
25
+  function __construct() {
26
+	$this->CI = & get_instance();
27 27
 	$this->CI->load->library('session');
28 28
 	$this->CI->load->database();
29 29
   }
30 30
 
31
-  function uset_timezone(){
31
+  function uset_timezone() {
32 32
 	    $account_data = $this->CI->session->userdata('accountinfo');
33
-	    return $account_data['timezone_id'] ;
33
+	    return $account_data['timezone_id'];
34 34
   }
35
-  function display_GMT($currDate,$fulldate = 1)
35
+  function display_GMT($currDate, $fulldate = 1)
36 36
   {	
37 37
       $number = $this->uset_timezone();
38
-      $SERVER_GMT='0';
38
+      $SERVER_GMT = '0';
39 39
 
40
-      $result=$this->CI->db->query("select gmtoffset from timezone where id =".$number);
40
+      $result = $this->CI->db->query("select gmtoffset from timezone where id =".$number);
41 41
       $timezone_offset = $result->result();
42 42
 
43 43
       $USER_GMT = $timezone_offset['0']->gmtoffset;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
       $year = $date_time_array['year'];
53 53
       $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
54 54
 
55
-      $timestamp = $timestamp+($USER_GMT-$SERVER_GMT);
55
+      $timestamp = $timestamp + ($USER_GMT - $SERVER_GMT);
56 56
       if ($fulldate == 1) {
57 57
 		$date = date("Y-m-d H:i:s", $timestamp);
58 58
       } else {
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
       return $date;
63 63
   }
64 64
 
65
-  function convert_to_GMT($currDate,$fulldate = 1){
65
+  function convert_to_GMT($currDate, $fulldate = 1) {
66 66
       $number = $this->uset_timezone();
67
-      $SERVER_GMT='0';
67
+      $SERVER_GMT = '0';
68 68
 
69
-      $result=$this->CI->db->query("select gmtoffset from timezone where id =".$number);
69
+      $result = $this->CI->db->query("select gmtoffset from timezone where id =".$number);
70 70
       $timezone_offset = $result->result();
71 71
 
72 72
       $USER_GMT = $timezone_offset['0']->gmtoffset;
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/csvreader.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2 2
 /**
3 3
 * CSVReader Class
4 4
 *
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 */
13 13
 class CSVReader {
14 14
 
15
-    var $fields;        /** columns names retrieved after parsing */
16
-    var $separator = ',';    /** separator used to explode each line */
15
+    var $fields; /** columns names retrieved after parsing */
16
+    var $separator = ','; /** separator used to explode each line */
17 17
 
18 18
     /**
19 19
      * Parse a text containing CSV formatted data.
@@ -34,23 +34,23 @@  discard block
 block discarded – undo
34 34
      * @param    string
35 35
      * @return    array
36 36
      */
37
-    function parse_file($p_Filepath,$config_variable,$check_header_flag=false) {
37
+    function parse_file($p_Filepath, $config_variable, $check_header_flag = false) {
38 38
         $lines = file($p_Filepath);
39 39
         //Giving line numbers
40
-        for($i=0;$i<sizeof($lines);$i++)
40
+        for ($i = 0; $i < sizeof($lines); $i++)
41 41
         {
42 42
         
43
-            if(trim($lines[$i]) != "")
43
+            if (trim($lines[$i]) != "")
44 44
             {
45 45
                 $columnname = explode($this->separator, $lines[$i]);
46
-                for($i=0;$i<sizeof($columnname);$i++)
46
+                for ($i = 0; $i < sizeof($columnname); $i++)
47 47
                 {
48
-                    $columnname[$i]=$columnname[$i];
48
+                    $columnname[$i] = $columnname[$i];
49 49
                 }
50 50
                  break;                    
51 51
             }
52 52
         }
53
-	return $this->parse_lines($lines,$config_variable,$check_header_flag);
53
+	return $this->parse_lines($lines, $config_variable, $check_header_flag);
54 54
     }
55 55
     /**
56 56
      * Parse an array of text lines containing CSV formatted data.
@@ -59,47 +59,47 @@  discard block
 block discarded – undo
59 59
      * @param    array
60 60
      * @return    array
61 61
      */
62
-    function parse_lines($p_CSVLines,$config_variable,$check_header_flag=false) {
62
+    function parse_lines($p_CSVLines, $config_variable, $check_header_flag = false) {
63 63
 //     echo "<pre>";
64
-         $t=0;    
65
-         $content=array();
66
-         $custom_array=array();
67
-         $i=0;
68
-         $flag_data=false;
69
-         $data_arr[0]=$config_variable;
70
-         $field_name_arr=array_keys($config_variable);
71
-	foreach( $p_CSVLines as $line_num => $line )
64
+         $t = 0;    
65
+         $content = array();
66
+         $custom_array = array();
67
+         $i = 0;
68
+         $flag_data = false;
69
+         $data_arr[0] = $config_variable;
70
+         $field_name_arr = array_keys($config_variable);
71
+	foreach ($p_CSVLines as $line_num => $line)
72 72
         {
73
-	  $line=trim($line);
74
-          if(!empty($line)){
73
+	  $line = trim($line);
74
+          if ( ! empty($line)) {
75 75
           // skip empty lines
76 76
 	      $elements = explode($this->separator, $line);
77 77
 	      
78
-	      if(array_filter($elements,'trim')) {
79
-		$custom_array[]=$elements;
78
+	      if (array_filter($elements, 'trim')) {
79
+		$custom_array[] = $elements;
80 80
 	      }
81 81
 	      $i++;
82 82
 	   }
83 83
         }
84 84
         
85
-        if($check_header_flag == 'on'){
85
+        if ($check_header_flag == 'on') {
86 86
          unset($custom_array[0]);
87 87
         }
88
-	 foreach($custom_array as $data){
89
-	  $j=0;
90
-	  foreach($data as $key=>$value){
91
-	    $value=str_replace('"', '', $value);
92
-	    $value=str_replace("'", '', $value);
93
-	    if(isset($field_name_arr[$j])){
94
-	        $field_key_value =$config_variable[$field_name_arr[$j]];
95
-		$value= strip_slashes(trim($value));
88
+	 foreach ($custom_array as $data) {
89
+	  $j = 0;
90
+	  foreach ($data as $key=>$value) {
91
+	    $value = str_replace('"', '', $value);
92
+	    $value = str_replace("'", '', $value);
93
+	    if (isset($field_name_arr[$j])) {
94
+	        $field_key_value = $config_variable[$field_name_arr[$j]];
95
+		$value = strip_slashes(trim($value));
96 96
                 $value = preg_replace('#<script.*</script>#is', '', $value);
97
-                if(isset($field_key_value) && !empty($field_key_value))
98
-		  $content[$field_key_value] =  strip_tags(filter_var($value, FILTER_SANITIZE_STRING));                  
97
+                if (isset($field_key_value) && ! empty($field_key_value))
98
+		  $content[$field_key_value] = strip_tags(filter_var($value, FILTER_SANITIZE_STRING));                  
99 99
 		$j++;
100 100
 	    }  
101 101
 	  }
102
-	  $data_arr[]=$content;
102
+	  $data_arr[] = $content;
103 103
         }
104 104
         return $data_arr;
105 105
     }
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/common.php 1 patch
Spacing   +425 added lines, -425 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 23
 ###############################################################################
24 24
 
25
-if (!defined('BASEPATH'))
25
+if ( ! defined('BASEPATH'))
26 26
     exit('No direct script access allowed');
27 27
 
28 28
 /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         if ($tablename == 'accounts' && $start_prifix_value != 0) {
89 89
             $length = strlen($start_prifix_value);
90 90
             $uname = substr($uname, $length);
91
-            $uname = $start_prifix_value . $uname;
91
+            $uname = $start_prifix_value.$uname;
92 92
         }
93 93
         return $uname;
94 94
     }
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
             $uname = $this->random_string($length);
114 114
             $uname = strtolower($uname);
115 115
             if (isset($default))
116
-                $uname = $default . $uname;
117
-            if (!in_array($uname, $number)) {
116
+                $uname = $default.$uname;
117
+            if ( ! in_array($uname, $number)) {
118 118
                 $where = array($field => $uname);
119 119
                 $acc_result = $this->CI->db_model->getSelect('Count(id) as count', $tablename, $where);
120 120
                 $acc_result = $acc_result->result_array();
121
-                if ($acc_result[0]['count'] == 0 && !in_array($uname, $number)) {
121
+                if ($acc_result[0]['count'] == 0 && ! in_array($uname, $number)) {
122 122
                     $number[] = $uname;
123 123
                     $j++;
124 124
                 }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             $where = array($select => $where);
141 141
         }
142 142
         $field_name = $this->CI->db_model->countQuery($select, $table, $where);
143
-        if (isset($field_name) && !empty($field_name)) {
143
+        if (isset($field_name) && ! empty($field_name)) {
144 144
             return $field_name;
145 145
         } else {
146 146
             return "0";
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         }
156 156
         $field_name = $this->CI->db_model->getSelect($select, $table, $where);
157 157
         $field_name = $field_name->result();
158
-        if (isset($field_name) && !empty($field_name)) {
158
+        if (isset($field_name) && ! empty($field_name)) {
159 159
             return $field_name[0]->$select;
160 160
         } else {
161 161
             return "";
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 
176 176
             $field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
177 177
             $field_name = $field_name->result();
178
-            if (isset($field_name) && !empty($field_name)) {
178
+            if (isset($field_name) && ! empty($field_name)) {
179 179
                 foreach ($select1 as $sel) {
180 180
                     if ($sel == 'number') {
181
-                        $value.="(" . $field_name[0]->$sel . ")";
181
+                        $value .= "(".$field_name[0]->$sel.")";
182 182
                     } else {
183
-                        $value.= $field_name[0]->$sel . " ";
183
+                        $value .= $field_name[0]->$sel." ";
184 184
                     }
185 185
                 }
186 186
             } else {
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
         $where = array("number" => $where);
197 197
         $field_name = $this->CI->db_model->getSelect("id,accountid,parent_id", 'dids', $where);
198 198
         $field_name = $field_name->result();
199
-        if (isset($field_name) && !empty($field_name)) {
199
+        if (isset($field_name) && ! empty($field_name)) {
200 200
             if (isset($field_name[0]) && $accountinfo['type'] != 1) {
201
-                if ($field_name[0]->accountid != 0 && $field_name[0]->parent_id ==0) {
202
-                    $flag_status = "<a href='../did_list_release/" . $field_name[0]->id . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
201
+                if ($field_name[0]->accountid != 0 && $field_name[0]->parent_id == 0) {
202
+                    $flag_status = "<a href='../did_list_release/".$field_name[0]->id."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
203 203
                 } else if ($field_name[0]->parent_id != 0) {
204
-                    $flag_status = "<a href='../did_list_release/" . $field_name[0]->id . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
204
+                    $flag_status = "<a href='../did_list_release/".$field_name[0]->id."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
205 205
                 } else {
206 206
                     $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
207 207
                 }
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
                 $field_name_re = $this->CI->db_model->getSelect("reseller_id", 'reseller_pricing', $where);
212 212
                 $field_name_re = $field_name_re->result();
213 213
 
214
-                if (isset($field_name_re) && !empty($field_name_re)) {
215
-                    $flag_status = "<a href='../did_list_release/" . $field_name[0]->id . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
214
+                if (isset($field_name_re) && ! empty($field_name_re)) {
215
+                    $flag_status = "<a href='../did_list_release/".$field_name[0]->id."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
216 216
                 } else {
217 217
                     $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
218 218
                 }
@@ -222,32 +222,32 @@  discard block
 block discarded – undo
222 222
         }
223 223
         return $flag_status;
224 224
     }
225
-    function check_did_avl_export($number){
226
-      $this->CI->db->where('number',$number);
225
+    function check_did_avl_export($number) {
226
+      $this->CI->db->where('number', $number);
227 227
       $this->CI->db->select('id,accountid,parent_id');
228
-      $status=null;
229
-      $did_info=(array)$this->CI->db->get('dids')->first_row();
230
-      $accountinfo=$this->CI->session->userdata('accountinfo');
231
-      if($did_info['accountid'] ==0 && $did_info['parent_id']==0){
232
-	$status='Not in use';
228
+      $status = null;
229
+      $did_info = (array)$this->CI->db->get('dids')->first_row();
230
+      $accountinfo = $this->CI->session->userdata('accountinfo');
231
+      if ($did_info['accountid'] == 0 && $did_info['parent_id'] == 0) {
232
+	$status = 'Not in use';
233 233
       }
234
-      elseif($accountinfo['type'] !=1){
235
-	if($did_info['accountid'] ==0 && $did_info['parent_id'] > 0){
236
-	  $status='Purchase by Reseller';
234
+      elseif ($accountinfo['type'] != 1) {
235
+	if ($did_info['accountid'] == 0 && $did_info['parent_id'] > 0) {
236
+	  $status = 'Purchase by Reseller';
237 237
 	}
238
-	if($did_info['accountid'] > 0 && $did_info['parent_id'] == 0){
239
-	  $status='Purchase by Customer';
238
+	if ($did_info['accountid'] > 0 && $did_info['parent_id'] == 0) {
239
+	  $status = 'Purchase by Customer';
240 240
 	}
241
-      }else{
242
-       $where_arr=array('note'=>$did_info['number'],"parent_id"=>$accountinfo['id']);
241
+      } else {
242
+       $where_arr = array('note'=>$did_info['number'], "parent_id"=>$accountinfo['id']);
243 243
        $this->db->where($where);
244 244
        $this->CI->db->select('reseller_id,parent_id');
245 245
        $reseller_pricing = (array)$this->db->get('reseller_pricing')->first_row();
246
-       if($reseller_pricing['reseller_id']==0 && $did_info['accountid']==0 && $did_info['parent_id']==$accountinfo['id']){
247
-        $status='Not in use';
246
+       if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0 && $did_info['parent_id'] == $accountinfo['id']) {
247
+        $status = 'Not in use';
248 248
        }
249
-       if($reseller_pricing['reseller_id']==0 && $did_info['accountid']==0){
250
-       $status='Not in use';
249
+       if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0) {
250
+       $status = 'Not in use';
251 251
        }
252 252
       }
253 253
       return $status;
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
     function check_did_avl_reseller($select, $table, $where) {
257 257
         $accountinfo = $this->CI->session->userdata('accountinfo');
258 258
         $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
259
-        $this->CI->db->where('number',$where);
259
+        $this->CI->db->where('number', $where);
260 260
         $this->CI->db->select('id,accountid,parent_id,number');
261
-        $did_info=(array)$this->CI->db->get('dids')->first_row();
262
-        if($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']){
263
-	    $flag_status = "<a href='../did_list_release/" . $did_info['id'] . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
261
+        $did_info = (array)$this->CI->db->get('dids')->first_row();
262
+        if ($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']) {
263
+	    $flag_status = "<a href='../did_list_release/".$did_info['id']."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(C)<span></a>";
264 264
 	}
265
-        else if($accountinfo['type']!=1 && $did_info['parent_id'] != $accountinfo['id']){
266
-	    $flag_status = "<a href='../did_list_release/" . $did_info['id'] . "' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
267
-        }else{
268
-	    $reseller_id= $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
269
-	    $where = array("note" => $did_info['number'],'parent_id'=>$reseller_id);
265
+        else if ($accountinfo['type'] != 1 && $did_info['parent_id'] != $accountinfo['id']) {
266
+	    $flag_status = "<a href='../did_list_release/".$did_info['id']."' title='Release' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
267
+        } else {
268
+	    $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
269
+	    $where = array("note" => $did_info['number'], 'parent_id'=>$reseller_id);
270 270
             $this->CI->db->where($where);
271 271
 	    $this->CI->db->select('reseller_id,id');
272
-	    $reseller_pricing_info=(array)$this->CI->db->get('reseller_pricing')->first_row();
273
-	    if (isset($reseller_pricing_info) && !empty($reseller_pricing_info)) {
274
-		  $flag_status="<a href='../did/did_reseller_edit/delete/".$reseller_pricing_info['id']."' title='Reliase' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
275
-	    }else{
276
-	      $flag_status="<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
272
+	    $reseller_pricing_info = (array)$this->CI->db->get('reseller_pricing')->first_row();
273
+	    if (isset($reseller_pricing_info) && ! empty($reseller_pricing_info)) {
274
+		  $flag_status = "<a href='../did/did_reseller_edit/delete/".$reseller_pricing_info['id']."' title='Reliase' onClick='return get_reliase_msg();'><span class=' label label-sm label-inverse_blue arrowed_blue-in' title='release'>Release(R)</span></a>";
275
+	    } else {
276
+	      $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
277 277
 	    }
278 278
         }
279 279
         return $flag_status;
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 
293 293
             $field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
294 294
             $field_name = $field_name->result();
295
-            if (isset($field_name) && !empty($field_name)) {
296
-                $value.= $field_name[0]->$select . ",";
295
+            if (isset($field_name) && ! empty($field_name)) {
296
+                $value .= $field_name[0]->$select.",";
297 297
             } else {
298 298
                 $value = "";
299 299
             }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
             if (isset($uri_segment[3])) {
326 326
                 return $week_arr;
327 327
             } else {
328
-                $week_drp = form_dropdown(array("name" => 'invoice_day','style'=>"width: 100% !important;" , "class" => "invoice_day"), $week_arr, $day);
328
+                $week_drp = form_dropdown(array("name" => 'invoice_day', 'style'=>"width: 100% !important;", "class" => "invoice_day"), $week_arr, $day);
329 329
                 return $week_drp;
330 330
             }
331 331
         }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 return $mon_arr;
338 338
             } else {
339 339
                 $day = $invoice_date > 0 ? $invoice_date : date('d');
340
-                $month_drp = form_dropdown(array("name" => 'invoice_day',"class" => "width_dropdown invoice_day"), $mon_arr, $day);
340
+                $month_drp = form_dropdown(array("name" => 'invoice_day', "class" => "width_dropdown invoice_day"), $mon_arr, $day);
341 341
                 return $month_drp;
342 342
             }
343 343
         }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
     }
350 350
 
351 351
     function set_routetype($status = '') {
352
-        $status_array = array( '0' => 'LCR','1' => 'COST',);
352
+        $status_array = array('0' => 'LCR', '1' => 'COST',);
353 353
         return $status_array;
354 354
     }
355 355
 
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
         $status_array = array('1' => 'Yes', '0' => 'No');
379 379
         return $status_array;
380 380
     }
381
-    function set_pin_allow($status=''){
382
-        $status_array = array('0' => 'Disable','1' => 'Enable');
381
+    function set_pin_allow($status = '') {
382
+        $status_array = array('0' => 'Disable', '1' => 'Enable');
383 383
         return $status_array;
384 384
     }
385
-    function set_pin_allow_customer($status=''){
386
-        $status_array = array('0' => 'No','1' => 'Yes');
385
+    function set_pin_allow_customer($status = '') {
386
+        $status_array = array('0' => 'No', '1' => 'Yes');
387 387
         return $status_array;
388 388
     }
389 389
     function get_allow($select = "", $table = "", $status) {
@@ -391,20 +391,20 @@  discard block
 block discarded – undo
391 391
     }
392 392
 
393 393
     function set_call_type($call_type = "") {
394
-        $call_type_array = array("-1" => "--Select--",'1' => 'DID-Local',"3"=>"SIP-DID", '0' => 'PSTN',  '2' => 'Other',);
394
+        $call_type_array = array("-1" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
395 395
         return $call_type_array;
396 396
     }
397
-    function set_call_type_search(){
398
-	$call_type_array = array("" => "--Select--",'1' => 'DID-Local',"3"=>"SIP-DID", '0' => 'PSTN',  '2' => 'Other',);
397
+    function set_call_type_search() {
398
+	$call_type_array = array("" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
399 399
         return $call_type_array;
400 400
     }
401 401
     function get_call_type($select = "", $table = "", $call_type) {
402
-        $call_type_array = array('1' => 'DID-Local',"3"=>"SIP-DID",'0' => 'PSTN',  '2' => 'Other','-1'=>"");
402
+        $call_type_array = array('1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other', '-1'=>"");
403 403
         return $call_type_array[$call_type];
404 404
     }
405 405
 
406 406
     function get_custom_call_type($call_type) {
407
-        $call_type_array = array('DID-Local' => '1',"SIP-DID"=>"3",'PSTN' => '0','Other' => '2',""=>"-1");
407
+        $call_type_array = array('DID-Local' => '1', "SIP-DID"=>"3", 'PSTN' => '0', 'Other' => '2', ""=>"-1");
408 408
         return $call_type_array[$call_type];
409 409
     }
410 410
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     }
430 430
 
431 431
 	function set_entity_type_email_mass($entity_type = "") {
432
-        $entity_array = array('' => "--Select--", '0' => 'Customer','1'=>'Reseller','3' => "Provider");
432
+        $entity_array = array('' => "--Select--", '0' => 'Customer', '1'=>'Reseller', '3' => "Provider");
433 433
         return $entity_array;
434 434
     }
435 435
 
@@ -466,21 +466,21 @@  discard block
 block discarded – undo
466 466
    show status on all grid
467 467
    */
468 468
    function get_status($select = "", $table = "", $status) {
469
-       if($select !='export'){
470
-        $status_tab=$this->encode($table);
471
-        $status['table']="'".$status_tab."'";
472
-        if($status['status'] == 0){
469
+       if ($select != 'export') {
470
+        $status_tab = $this->encode($table);
471
+        $status['table'] = "'".$status_tab."'";
472
+        if ($status['status'] == 0) {
473 473
 	$status_array = '<div style="width: 100%; text-align: -moz-center; padding: 0;"><input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id=switch'.$status['id'].' value='.$status['status'].' onclick="javascript:processForm('.$status['id'].','.$status['table'].')" checked>
474 474
 	<label class="onoffswitch-label" for=switch'.$status["id"].'>
475 475
      	<span class="onoffswitch-inner"></span>
476 476
 	</label></div>';
477
-	}else{
477
+	} else {
478 478
 	$status_array = '<div style="width: 100%; text-align: -moz-center; padding: 0;"><input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id=switch'.$status['id'].' value='.$status['status'].' onclick="javascript:processForm('.$status['id'].','.$status['table'].')">
479 479
 	<label class="onoffswitch-label" for=switch'.$status["id"].'>
480 480
      	<span class="onoffswitch-inner"></span>
481 481
 	</label></div>';
482 482
 	}
483
-	}else{
483
+	} else {
484 484
 		return ($status == 0) ? "Active" : "Inactive";
485 485
 	}
486 486
 	return $status_array;
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
         return ($status == 0) ? "Yes" : "No";
495 495
     }
496 496
     
497
-    function get_import_status($status){
497
+    function get_import_status($status) {
498 498
      return strtolower(trim($status)) == 'active' ? 0 : 1;
499 499
      
500 500
     }
501
-    function get_did_status($select,$table,$status){
501
+    function get_did_status($select, $table, $status) {
502 502
     
503
-      return ($status['status']==0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
503
+      return ($status['status'] == 0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
504 504
     }
505 505
    
506 506
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         }
512 512
         $invoice_res = $this->CI->db_model->select($select, "invoices", $where, $order_by, "DESC", "1", "0");
513 513
         if ($invoice_res->num_rows > 0) {
514
-            $invoice_info = (array) $invoice_res->first_row();
514
+            $invoice_info = (array)$invoice_res->first_row();
515 515
             return $invoice_info[$select];
516 516
         }
517 517
         return false;
@@ -537,23 +537,23 @@  discard block
 block discarded – undo
537 537
 
538 538
     function convert_to_currency($select = "", $table = "", $amount) {
539 539
         $this->CI->load->model('common_model');
540
-        return $this->CI->common_model->calculate_currency($amount,'','',true,false);
540
+        return $this->CI->common_model->calculate_currency($amount, '', '', true, false);
541 541
     }
542
-    function account_number_icon($select = "", $table = "", $number){
543
-    $return_value='';
544
-    $where=array('number'=>$number);
545
-    $account_res = (array)$this->CI->db->get_where("accounts",$where)->first_row();
546
-    if($account_res['type'] == 0){
547
-    $return_value= '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>". $account_res['number']." </span>";    
542
+    function account_number_icon($select = "", $table = "", $number) {
543
+    $return_value = '';
544
+    $where = array('number'=>$number);
545
+    $account_res = (array)$this->CI->db->get_where("accounts", $where)->first_row();
546
+    if ($account_res['type'] == 0) {
547
+    $return_value = '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>".$account_res['number']." </span>";    
548 548
     }
549
-    if($account_res['type']==3){
550
-    $return_value='<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res['number']." </span>";
549
+    if ($account_res['type'] == 3) {
550
+    $return_value = '<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res['number']." </span>";
551 551
     }
552
-    if($account_res['type']== -1 || $account_res['type']==2){
553
-      $return_value='<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res['number']." </span>";
552
+    if ($account_res['type'] == -1 || $account_res['type'] == 2) {
553
+      $return_value = '<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res['number']." </span>";
554 554
     }
555
-    if($account_res['type']== 4){
556
-      $return_value='<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res['number']." </span>";
555
+    if ($account_res['type'] == 4) {
556
+      $return_value = '<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res['number']." </span>";
557 557
     }
558 558
     return $return_value;
559 559
     }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
 
630 630
     function search_string_type($status = '') {
631
-        $status_array = array('5'=>"Begins With",'1' => 'Contains', '2' => 'Doesnt Contain', '3' => 'Is Equal To', '4' => 'Is Not Equal To',"6"=>"Ends With");
631
+        $status_array = array('5'=>"Begins With", '1' => 'Contains', '2' => 'Doesnt Contain', '3' => 'Is Equal To', '4' => 'Is Not Equal To', "6"=>"Ends With");
632 632
         return $status_array;
633 633
     }
634 634
 
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
     }
650 650
 
651 651
     function convert_to_percentage($select = "", $table = "", $amount) {
652
-        return round($amount, 2) . " %";
652
+        return round($amount, 2)." %";
653 653
     }
654 654
 
655 655
     function convert_to_minutes($select = "", $table = "", $amount) {
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
         return $status_array;
662 662
     }
663 663
     
664
-    	function set_routetype_status($select= ''){
664
+    	function set_routetype_status($select = '') {
665 665
         $status_array = array("" => "--Select--",
666 666
             "0" => "LCR",
667 667
             "1" => "COST"
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
             $array = explode(",", $attachement);
677 677
             $str = '';	
678 678
             foreach ($array as $key => $val) {
679
-                $link = base_url() . "email/email_history_list_attachment/" . $val;
680
-                $str.="<a href='" . $link . "' title='" . $val . "' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a>&nbsp;&nbsp;";
679
+                $link = base_url()."email/email_history_list_attachment/".$val;
680
+                $str .= "<a href='".$link."' title='".$val."' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a>&nbsp;&nbsp;";
681 681
             }
682 682
             return $str;
683 683
         } else {
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
     function get_action_buttons($buttons_arr, $linkid) {
766 766
         $ret_url = '';
767
-        if (!empty($buttons_arr) && $buttons_arr != '') {
767
+        if ( ! empty($buttons_arr) && $buttons_arr != '') {
768 768
             foreach ($buttons_arr as $button_key => $buttons_params) {
769 769
                 if (strtoupper($button_key) == "EDIT") {
770 770
                     $ret_url .= $this->build_edit_button($buttons_params, $linkid);
@@ -833,31 +833,31 @@  discard block
 block discarded – undo
833 833
     }
834 834
 
835 835
     function build_delete_button_animap($url, $linkid) {
836
-        $link = base_url() . $url . "" . $linkid;
837
-        return '<a href="javascript:void(0)" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg_destination(' . $linkid . ');"><i class="fa fa-trash fa-fw"></i></a>';
836
+        $link = base_url().$url."".$linkid;
837
+        return '<a href="javascript:void(0)" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg_destination('.$linkid.');"><i class="fa fa-trash fa-fw"></i></a>';
838 838
     }
839 839
 
840 840
     function build_edit_button_animap($button_params, $linkid) {
841
-        $link = base_url() . $button_params->url . "" . $linkid;
842
-        return '<a href="javascript:void(0);" id="destination_new" class="btn btn-royelblue btn-sm" onclick="return get_destination(' . $linkid . ');" title="Update"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
841
+        $link = base_url().$button_params->url."".$linkid;
842
+        return '<a href="javascript:void(0);" id="destination_new" class="btn btn-royelblue btn-sm" onclick="return get_destination('.$linkid.');" title="Update"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
843 843
     }
844 844
 
845 845
     function build_animap_button($button_params, $linkid) {
846
-        $link = base_url() . $button_params->url . "" . $linkid;
847
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm animap_image" rel="facebox" title="ANI Map"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
846
+        $link = base_url().$button_params->url."".$linkid;
847
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm animap_image" rel="facebox" title="ANI Map"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
848 848
     }
849 849
 
850 850
     function build_edit_button($button_params, $linkid) {
851
-        $link = base_url() . $button_params->url . "" . $linkid;
851
+        $link = base_url().$button_params->url."".$linkid;
852 852
        
853 853
         if ($button_params->mode == 'popup') {
854
-            $rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
855
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="Edit" ="small"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
854
+            $rel = (isset($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox";
855
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="Edit" ="small"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
856 856
             
857
-        }else if(strpos($link,'customer_edit') !== false){
858
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
859
-        }else {
860
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
857
+        } else if (strpos($link, 'customer_edit') !== false) {
858
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
859
+        } else {
860
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
861 861
         }
862 862
     }
863 863
 
@@ -865,18 +865,18 @@  discard block
 block discarded – undo
865 865
       For Edit on Account number or name
866 866
      **/
867 867
     function build_custome_edit_button($button_params, $field, $linkid) {
868
-        $link = base_url() . $button_params->url . "" . $linkid;
869
-        if(isset($button_params->layout)){
868
+        $link = base_url().$button_params->url."".$linkid;
869
+        if (isset($button_params->layout)) {
870 870
 			if ($button_params->mode == 'popup') {
871
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">' . $field . '</a>&nbsp;';
871
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">'.$field.'</a>&nbsp;';
872 872
 			} else {
873
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a>&nbsp;';
873
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a>&nbsp;';
874 874
 			}
875
-		}else{ 
875
+		} else { 
876 876
 			if ($button_params->mode == 'popup') {
877
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">' . $field . '</a>&nbsp;';
877
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">'.$field.'</a>&nbsp;';
878 878
 			} else {
879
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a>&nbsp;';
879
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a>&nbsp;';
880 880
 			}
881 881
 		}
882 882
     }
@@ -884,126 +884,126 @@  discard block
 block discarded – undo
884 884
     /************************************ */
885 885
 
886 886
     function build_edit_button_restore($button_params, $linkid) {
887
-        $link = base_url() . $button_params->url . "" . $linkid;
887
+        $link = base_url().$button_params->url."".$linkid;
888 888
         if ($button_params->mode == 'popup') {
889
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Restore" onClick="return get_alert_msg();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
889
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Restore" onClick="return get_alert_msg();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
890 890
         } else {
891
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Restore" onClick="return get_alert_msg_restore();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
891
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Restore" onClick="return get_alert_msg_restore();"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
892 892
         }
893 893
     }
894 894
 
895 895
     function build_delete_button($url, $linkid) {
896
-        $flag='0';
897
-        $data=  explode("/",$url);
898
-        $link = base_url() . $url . "" . $linkid;
899
-        foreach($data as $key=>$value){
900
-            if($value == 'price_delete')
896
+        $flag = '0';
897
+        $data = explode("/", $url);
898
+        $link = base_url().$url."".$linkid;
899
+        foreach ($data as $key=>$value) {
900
+            if ($value == 'price_delete')
901 901
                 $flag = '1';
902
-            if($value == 'trunk_remove')
903
-                $flag='2';
904
-            if($value == 'customer_delete' ||$value =='provider_delete')
905
-                $flag='3';
906
-            if($value == 'reseller_delete')
907
-                $flag='4';
902
+            if ($value == 'trunk_remove')
903
+                $flag = '2';
904
+            if ($value == 'customer_delete' || $value == 'provider_delete')
905
+                $flag = '3';
906
+            if ($value == 'reseller_delete')
907
+                $flag = '4';
908 908
             }    
909
-            if($flag=='1'){
910
-                $where=array('pricelist_id'=>$linkid,'deleted !=' =>'1');
911
-                $customer_cnt=$this->get_field_count('id','accounts',$where);
912
-                    $where=array('pricelist_id'=>$linkid);
913
-                    $rategroup_cnt=$this->get_field_count('id','routes',$where);
914
-                    if($rategroup_cnt > 0 || $customer_cnt > 0 ){
909
+            if ($flag == '1') {
910
+                $where = array('pricelist_id'=>$linkid, 'deleted !=' =>'1');
911
+                $customer_cnt = $this->get_field_count('id', 'accounts', $where);
912
+                    $where = array('pricelist_id'=>$linkid);
913
+                    $rategroup_cnt = $this->get_field_count('id', 'routes', $where);
914
+                    if ($rategroup_cnt > 0 || $customer_cnt > 0) {
915 915
                         
916
-                        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$rategroup_cnt.','.$customer_cnt.','.$linkid.',1);"><i class="fa fa-trash fa-fw"></i></a>';
916
+                        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$rategroup_cnt.','.$customer_cnt.','.$linkid.',1);"><i class="fa fa-trash fa-fw"></i></a>';
917 917
                     }
918
-                    else{
919
-                        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
918
+                    else {
919
+                        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
920 920
                     }
921 921
             }
922
-            if($flag=='2'){
923
-                $where=array('trunk_id'=>$linkid);
924
-                $trunk_cnt=$this->get_field_count('id','outbound_routes',$where);
925
-                if($trunk_cnt > 0){
926
-                    return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$trunk_cnt.',null,'.$linkid.',2);"><i class="fa fa-trash fa-fw"></i></a>';
922
+            if ($flag == '2') {
923
+                $where = array('trunk_id'=>$linkid);
924
+                $trunk_cnt = $this->get_field_count('id', 'outbound_routes', $where);
925
+                if ($trunk_cnt > 0) {
926
+                    return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message('.$trunk_cnt.',null,'.$linkid.',2);"><i class="fa fa-trash fa-fw"></i></a>';
927 927
                 }
928
-                else{
929
-                    return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
928
+                else {
929
+                    return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
930 930
                 }
931 931
             }
932
-            if($flag == '3'){
933
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);">
932
+            if ($flag == '3') {
933
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);">
934 934
 		<i class="fa fa-trash fa-fw"></i></a>';
935 935
             }
936
-            if($flag == '4'){
937
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);">
936
+            if ($flag == '4') {
937
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);">
938 938
 		<i class="fa fa-trash fa-fw"></i></a>';
939 939
             }
940
-            if($flag=='0' && $url.$linkid !='accounts/admin_delete/1' ){
941
-                return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
940
+            if ($flag == '0' && $url.$linkid != 'accounts/admin_delete/1') {
941
+                return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_msg();"><i class="fa fa-trash fa-fw"></i></a>';
942 942
             }  
943 943
     }
944 944
 
945 945
     function build_view_button($button_params, $linkid) {
946
-        $link = base_url() . $button_params->url . "" . $linkid;
946
+        $link = base_url().$button_params->url."".$linkid;
947 947
         if ($button_params->mode == 'popup') {
948
-			$rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
949
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
948
+			$rel = (isset($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox";
949
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="'.$rel.'" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
950 950
         } else {
951
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
951
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
952 952
         }
953 953
     }
954 954
 
955 955
     function build_add_taxes_button($button_params, $linkid) {
956
-        $link = base_url() . $button_params->url . "" . $linkid;
956
+        $link = base_url().$button_params->url."".$linkid;
957 957
         if ($button_params->mode == 'popup') {
958
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
958
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
959 959
         } else {
960
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
960
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
961 961
         }
962 962
     }
963 963
 
964 964
     function build_add_download_database_button($url, $linkid) {
965
-        $link = base_url() . $url . "" . $linkid;
966
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm "  title="Download Database" ><i class="fa-fw fa fa-file-archive-o"></i></a>&nbsp;';
965
+        $link = base_url().$url."".$linkid;
966
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm "  title="Download Database" ><i class="fa-fw fa fa-file-archive-o"></i></a>&nbsp;';
967 967
     }
968 968
 
969 969
     function build_add_callerid_button($button_params, $linkid) {
970
-        $link = base_url() . $button_params->url . "" . $linkid;
970
+        $link = base_url().$button_params->url."".$linkid;
971 971
         if ($button_params->mode == 'popup') {
972
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Force Caller Id"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
972
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Force Caller Id"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
973 973
         } else {
974
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
974
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
975 975
         }
976 976
     }
977 977
 
978 978
     function build_start_button($url, $linkid) {
979
-        $link = base_url() . $url . "" . $linkid;
979
+        $link = base_url().$url."".$linkid;
980 980
 
981
-        return '<a href="' . $link . '" class=""  title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a>&nbsp;';
981
+        return '<a href="'.$link.'" class=""  title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a>&nbsp;';
982 982
     }
983 983
 
984 984
     function build_stop_button($url, $linkid) {
985
-        $link = base_url() . $url . "" . $linkid;
986
-        return '<a href="' . $link . '" class=""  title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a>&nbsp;';
985
+        $link = base_url().$url."".$linkid;
986
+        return '<a href="'.$link.'" class=""  title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a>&nbsp;';
987 987
     }
988 988
 
989 989
     function build_reload_button($url, $linkid) {
990
-        $link = base_url() . $url . "" . $linkid;
991
-        return '<a href="' . $link . '" class=""  title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a>&nbsp;';
990
+        $link = base_url().$url."".$linkid;
991
+        return '<a href="'.$link.'" class=""  title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a>&nbsp;';
992 992
     }
993 993
 
994 994
     function build_rescan_button($url, $linkid) {
995
-        $link = base_url() . $url . "" . $linkid;
996
-        return '<a href="' . $link . '" class=""  title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a>&nbsp;';
995
+        $link = base_url().$url."".$linkid;
996
+        return '<a href="'.$link.'" class=""  title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a>&nbsp;';
997 997
     }
998 998
 
999 999
     function build_add_payment_button($url, $linkid) {
1000
-        $link = base_url() . $url . "" . $linkid;
1001
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a>&nbsp;';
1000
+        $link = base_url().$url."".$linkid;
1001
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a>&nbsp;';
1002 1002
     }
1003 1003
 
1004 1004
     function build_add_download_button($url, $linkid) {
1005
-        $link = base_url() . $url . "" . $linkid;
1006
-        return '<a href="' . $link . '" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp;';
1005
+        $link = base_url().$url."".$linkid;
1006
+        return '<a href="'.$link.'" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp;';
1007 1007
     }
1008 1008
 
1009 1009
     /*
@@ -1012,11 +1012,11 @@  discard block
 block discarded – undo
1012 1012
      */
1013 1013
 
1014 1014
     function build_edit_button_resend($button_params, $linkid) {
1015
-        $link = base_url() . $button_params->url . "" . $linkid;
1015
+        $link = base_url().$button_params->url."".$linkid;
1016 1016
         if ($button_params->mode == 'popup') {
1017
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1017
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1018 1018
         } else {
1019
-            return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1019
+            return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1020 1020
         }
1021 1021
     }
1022 1022
 
@@ -1031,17 +1031,17 @@  discard block
 block discarded – undo
1031 1031
     function mail_to_users($type, $accountinfo, $attachment = "", $amount = "") {
1032 1032
 		$subject = "";
1033 1033
         $settings_reply_email = '[email protected]';
1034
-        $reseller_id=$accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0;
1035
-		$where="accountid IN ('".$reseller_id."','1')";
1034
+        $reseller_id = $accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0;
1035
+		$where = "accountid IN ('".$reseller_id."','1')";
1036 1036
         $this->CI->db->where($where);
1037 1037
         $this->CI->db->select('emailaddress');
1038 1038
         $this->CI->db->order_by('accountid', 'desc');
1039 1039
         $this->CI->db->limit(1);
1040 1040
         $invoiceconf = $this->CI->db->get('invoice_conf');
1041 1041
         $invoiceconf = (array)$invoiceconf->first_row();
1042
-        $settings_reply_email=$invoiceconf['emailaddress'];
1043
-        $company_name=Common_model::$global_config['system_config']['company_name'];
1044
-        $company_website=Common_model::$global_config['system_config']['company_website'];
1042
+        $settings_reply_email = $invoiceconf['emailaddress'];
1043
+        $company_name = Common_model::$global_config['system_config']['company_name'];
1044
+        $company_website = Common_model::$global_config['system_config']['company_website'];
1045 1045
         $where = array('name' => $type);
1046 1046
         $query = $this->CI->db_model->getSelect("*", "default_templates", $where);
1047 1047
         $query = $query->result();
@@ -1052,106 +1052,106 @@  discard block
 block discarded – undo
1052 1052
         $message = str_replace("#COMPANY_NAME#", $company_name, $message);
1053 1053
         $message = str_replace("#COMPANY_WEBSITE#", $company_website, $message);
1054 1054
         $message = str_replace("</p>", "", $message);
1055
-		if(isset($accountinfo['refill_amount']) && $accountinfo['refill_amount']!= ""){
1055
+		if (isset($accountinfo['refill_amount']) && $accountinfo['refill_amount'] != "") {
1056 1056
 			$refillamount = $accountinfo['refill_amount'];
1057
-		}else{
1057
+		} else {
1058 1058
 			$refillamount = "0";
1059 1059
 		}
1060 1060
 		
1061 1061
         switch ($type) {
1062 1062
             case 'email_add_user':
1063
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1063
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1064 1064
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);
1065 1065
                 $message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1066 1066
                 $message = str_replace('#LINK#', $accountinfo['confirm'], $message);
1067 1067
                 break;
1068 1068
             case 'email_forgot_user':
1069
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1069
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1070 1070
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);
1071 1071
                 $message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1072 1072
                 $message = str_replace('#LINK#', $accountinfo['link'], $message);
1073 1073
                 break;
1074 1074
 
1075 1075
             case 'email_forgot_confirmation':
1076
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1076
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1077 1077
                 $message = str_replace('#CONFIRM#', $accountinfo['confirm'], $message);
1078 1078
                 break;
1079 1079
 
1080 1080
             case 'email_signup_confirmation':
1081
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1081
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1082 1082
                 $message = str_replace('#CONFIRM#', $accountinfo['confirm'], $message);
1083 1083
                 break;
1084 1084
             case 'add_sip_device':
1085
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1085
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1086 1086
                 $message = str_replace('#USERNAME#', $accountinfo['number'], $message);
1087 1087
                 $message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1088 1088
                 break;
1089 1089
                               
1090 1090
             case 'voip_account_refilled':
1091
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1091
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1092 1092
                 $message = str_replace('#REFILLBALANCE#', $accountinfo['refill_amount'], $message);
1093 1093
                 $message = str_replace('#BALANCE#', $accountinfo['refill_amount'] + $accountinfo['balance'], $message);
1094 1094
                 break;
1095 1095
             case 'voip_child_account_refilled':
1096
-                $reseller_number= $this->CI->common->get_field_name('number', 'accounts', $accountinfo['reseller_id']);
1097
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1096
+                $reseller_number = $this->CI->common->get_field_name('number', 'accounts', $accountinfo['reseller_id']);
1097
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1098 1098
                 $message = str_replace('#REFILLBALANCE#', $accountinfo['refill_amount'], $message);
1099 1099
                 $message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1100
-                $message = str_replace('#ACCOUNTNUMBER#',$reseller_number, $message);
1100
+                $message = str_replace('#ACCOUNTNUMBER#', $reseller_number, $message);
1101 1101
                 break;
1102 1102
             case 'add_subscription':
1103
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1103
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1104 1104
                 break;
1105 1105
             case 'remove_subscription':
1106
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1106
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1107 1107
                 break;
1108 1108
             case 'add_package':
1109
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1109
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1110 1110
                 break;
1111 1111
             case 'remove_package':
1112
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1112
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1113 1113
                 break;
1114 1114
             case 'email_calling_card':
1115
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1115
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1116 1116
                 $message = str_replace('#CARDNUMBER#', $accountinfo['cardnumber'], $message);
1117 1117
                 $message = str_replace('#PIN#', $accountinfo['pin'], $message);
1118 1118
                 $message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1119 1119
                 break;
1120 1120
             case 'email_low_balance';
1121
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1121
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1122 1122
                 $to_currency = $this->CI->common->get_field_name('currency', 'currency', $accountinfo['currency_id']);
1123 1123
                 $balance = $this->CI->common_model->calculate_currency($accountinfo['balance'], "", $to_currency, true, true);
1124 1124
                 $message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1125 1125
                 break;
1126 1126
             case 'email_new_invoice';
1127
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1127
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1128 1128
                 $message = str_replace('#AMOUNT#', $amount, $message);
1129 1129
                 $message = str_replace('#INVOICE_NUMBER#', $amount, $message);
1130 1130
                 $subject = $query[0]->subject;
1131 1131
                 $subject = str_replace("#INVOICE_NUMBER#", $amount, $subject);
1132 1132
                 break;
1133 1133
              case 'email_add_did';
1134
-				if(isset($accountinfo['did_maxchannels']) && $accountinfo['did_maxchannels']!= ""){
1134
+				if (isset($accountinfo['did_maxchannels']) && $accountinfo['did_maxchannels'] != "") {
1135 1135
 					$accountinfo['did_maxchannels'] = $accountinfo['did_maxchannels'];
1136
-				}else if($accountinfo['did_maxchannels'] == "0"){
1136
+				} else if ($accountinfo['did_maxchannels'] == "0") {
1137 1137
 							$accountinfo['did_maxchannels'] = "Unlimited";
1138
-				}else{
1138
+				} else {
1139 1139
 					$accountinfo['did_maxchannels'] = "Unlimited";
1140 1140
 				}
1141
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1142
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'] , $message);
1143
-                $message = str_replace('#COUNTRYNAME#',$accountinfo['did_country_id'], $message);
1144
-                $message = str_replace('#SETUPFEE#',$accountinfo['did_setup'], $message);
1145
-                $message = str_replace('#MONTHLYFEE#',$accountinfo['did_monthlycost'], $message);
1146
-                $message = str_replace('#MAXCHANNEL#',$accountinfo['did_maxchannels'], $message);
1141
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1142
+                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'], $message);
1143
+                $message = str_replace('#COUNTRYNAME#', $accountinfo['did_country_id'], $message);
1144
+                $message = str_replace('#SETUPFEE#', $accountinfo['did_setup'], $message);
1145
+                $message = str_replace('#MONTHLYFEE#', $accountinfo['did_monthlycost'], $message);
1146
+                $message = str_replace('#MAXCHANNEL#', $accountinfo['did_maxchannels'], $message);
1147 1147
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1148 1148
 				$subject = $query[0]->subject;
1149 1149
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
1150 1150
 				$subject = str_replace("#DIDNUMBER#", $accountinfo['did_number'], $subject);
1151 1151
                 break;
1152 1152
             case 'email_remove_did';
1153
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1154
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'],$message);
1153
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1154
+                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'], $message);
1155 1155
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1156 1156
 				$subject = $query[0]->subject;
1157 1157
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
@@ -1159,9 +1159,9 @@  discard block
 block discarded – undo
1159 1159
                 break;
1160 1160
         }
1161 1161
         
1162
-        if($subject == ""){
1162
+        if ($subject == "") {
1163 1163
 			$subject = $query[0]->subject;
1164
-			$subject = str_replace("#NAME#", $accountinfo['first_name'] . " " . $accountinfo['last_name'], $subject);
1164
+			$subject = str_replace("#NAME#", $accountinfo['first_name']." ".$accountinfo['last_name'], $subject);
1165 1165
 			$subject = str_replace("#COMPANY_NAME#", $company_name, $subject);	
1166 1166
 		}
1167 1167
         $account_id = (isset($accountinfo['last_id']) && $accountinfo['last_id'] != "") ? $accountinfo['last_id'] : $accountinfo['id'];
@@ -1245,13 +1245,13 @@  discard block
 block discarded – undo
1245 1245
         $result = $this->CI->db->get('invoice_details');
1246 1246
         if ($result->num_rows() > 0) {
1247 1247
             $result = $result->result_array();
1248
-	    if($select == 'debit'){
1249
-		if($result[0]['item_type'] == 'POSTCHARG'){
1248
+	    if ($select == 'debit') {
1249
+		if ($result[0]['item_type'] == 'POSTCHARG') {
1250 1250
 	            return $this->convert_to_currency('', '', $result[0]['debit']);
1251
-		}else{
1251
+		} else {
1252 1252
 	            return $this->convert_to_currency('', '', $result[0]['credit']);
1253 1253
 		}
1254
-	    }else{
1254
+	    } else {
1255 1255
 		   return $result[0][$select];
1256 1256
 	    }
1257 1257
         } else {
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 
1303 1303
             $timezone_result = $timezone_result->result_array();
1304 1304
             foreach ($timezone_result as $data) {
1305
-                $gmtoffset+=$data['gmtoffset'];
1305
+                $gmtoffset += $data['gmtoffset'];
1306 1306
             }
1307 1307
         }
1308 1308
 // 	  echo $gmtoffset;exit;
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
     }
1367 1367
 
1368 1368
     function get_refill_coupon_used($select = '', $table = '', $status) {
1369
-        return $status['status'] == 2 ? '<img src= "'.base_url().'assets/images/true.png" style="height:20px;width:20px;" title="Yes">' : '<img src= "'. base_url().'/assets/images/false.png" style="height:20px;width:20px;" title="No">';
1369
+        return $status['status'] == 2 ? '<img src= "'.base_url().'assets/images/true.png" style="height:20px;width:20px;" title="Yes">' : '<img src= "'.base_url().'/assets/images/false.png" style="height:20px;width:20px;" title="No">';
1370 1370
     }
1371 1371
 
1372 1372
     /*     * *******
@@ -1444,20 +1444,20 @@  discard block
 block discarded – undo
1444 1444
         $status_array = array('0' => 'Enable', '1' => 'Disable');
1445 1445
         return $status_array;
1446 1446
     }
1447
-    function custom_status($status){
1447
+    function custom_status($status) {
1448 1448
 		$status_array = array('0' => 'Yes', '1' => 'No');
1449 1449
         return $status_array;
1450 1450
     }
1451 1451
     
1452
-    function custom_status_active($status){
1452
+    function custom_status_active($status) {
1453 1453
       $status_array = array('0' => 'Active', '1' => 'InActive');
1454 1454
       return $status_array;
1455 1455
     }
1456
-    function custom_status_true($status){
1456
+    function custom_status_true($status) {
1457 1457
       $status_array = array('0' => 'TRUE', '1' => 'FALSE');
1458 1458
       return $status_array;
1459 1459
     }
1460
-    function custom_status_voicemail($status){
1460
+    function custom_status_voicemail($status) {
1461 1461
       $status_array = array('true' => 'True', 'false' => 'False');
1462 1462
       return $status_array;
1463 1463
     }
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
         return $status_array;
1485 1485
     }
1486 1486
 	
1487
-    function enable_disable_option(){
1487
+    function enable_disable_option() {
1488 1488
         $option_array = array('0' => 'Enable', '1' => 'Disable');
1489 1489
         return $option_array;
1490 1490
     }
@@ -1512,14 +1512,14 @@  discard block
 block discarded – undo
1512 1512
         $status_array = array('1' => 'Enable', '0' => 'Disable',);
1513 1513
         return $status_array;
1514 1514
     }
1515
-    function default_signup_rategroup(){
1515
+    function default_signup_rategroup() {
1516 1516
         $this->CI->db->select("id,name");
1517
-        $this->CI->db->where("status",0);
1518
-        $this->CI->db->where("reseller_id",0);
1519
-        $pricelist_result=$this->CI->db->get("pricelists")->result_array();
1520
-        $pricelist_arr=array();
1521
-        foreach($pricelist_result as $result){
1522
-            $pricelist_arr[$result['id']]=$result['name'];
1517
+        $this->CI->db->where("status", 0);
1518
+        $this->CI->db->where("reseller_id", 0);
1519
+        $pricelist_result = $this->CI->db->get("pricelists")->result_array();
1520
+        $pricelist_arr = array();
1521
+        foreach ($pricelist_result as $result) {
1522
+            $pricelist_arr[$result['id']] = $result['name'];
1523 1523
         }
1524 1524
         return $pricelist_arr;
1525 1525
         
@@ -1593,17 +1593,17 @@  discard block
 block discarded – undo
1593 1593
       Calculate Currency manually.
1594 1594
      */
1595 1595
 
1596
-    function calculate_currency_manually($currency_info, $amount, $show_currency_flag = true,$number_format=true) {
1596
+    function calculate_currency_manually($currency_info, $amount, $show_currency_flag = true, $number_format = true) {
1597 1597
         $decimal_points = $currency_info['decimalpoints'];
1598 1598
         $system_currency_rate = $currency_info['base_currency']['currencyrate'];
1599 1599
         $user_currency_rate = $currency_info['user_currency']['currencyrate'];
1600
-        $calculated_amount=(float)(($amount * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']); 
1601
-        if($number_format){
1602
-         $calculated_amount = number_format($calculated_amount,$currency_info['decimalpoints']);
1600
+        $calculated_amount = (float)(($amount * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']); 
1601
+        if ($number_format) {
1602
+         $calculated_amount = number_format($calculated_amount, $currency_info['decimalpoints']);
1603 1603
         }
1604
-        if ($show_currency_flag){
1604
+        if ($show_currency_flag) {
1605 1605
           return $calculated_amount." ".$currency_info['user_currency']['currency'];
1606
-        }else{
1606
+        } else {
1607 1607
           return $calculated_amount;
1608 1608
         }
1609 1609
     }
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
     }
1619 1619
 
1620 1620
     function set_summarycustomer_groupby($status = '') {
1621
-        $status_array = array('' => "--Select--", 'accountid' => 'Account', 'pattern' => 'Code','package_id'=>"Package");
1621
+        $status_array = array('' => "--Select--", 'accountid' => 'Account', 'pattern' => 'Code', 'package_id'=>"Package");
1622 1622
         return $status_array;
1623 1623
     }
1624 1624
 
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
         $accountinfo = $this->CI->session->userdata('accountinfo');
1635 1635
         //Get User Currency id 
1636 1636
         $user_currency_id = $accountinfo['currency_id'] > 0 ? $accountinfo['currency_id'] : $base_currency;
1637
-        $where = "currency = '" . $base_currency . "' OR id= " . $user_currency_id;
1637
+        $where = "currency = '".$base_currency."' OR id= ".$user_currency_id;
1638 1638
         $this->CI->db->where($where);
1639 1639
         $this->CI->db->select('*');
1640 1640
         $currency_result = $this->CI->db->get('currency');
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
                 }
1653 1653
             }
1654 1654
         } else if ($currency_result->num_rows() == 1) {
1655
-            $currency_info['user_currency'] = $currency_info['base_currency'] = (array) $currency_result->first_row();
1655
+            $currency_info['user_currency'] = $currency_info['base_currency'] = (array)$currency_result->first_row();
1656 1656
         }
1657 1657
         //Get Decimal points as per defined from system.
1658 1658
         $currency_info['decimalpoints'] = Common_model::$global_config['system_config']['decimalpoints'];
@@ -1661,15 +1661,15 @@  discard block
 block discarded – undo
1661 1661
 
1662 1662
     function convert_to_show_in($search_name = "", $table = "", $second) {
1663 1663
         $search_arr = $this->CI->session->userdata($search_name);
1664
-        $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
1665
-        return ($show_seconds === 'minutes') ? ($second > 0 ) ?
1666
-                        sprintf('%02d',$second / 60) . ":" . sprintf('%02d', ($second % 60)) : "00:00"  : sprintf('%02d', $second);
1664
+        $show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
1665
+        return ($show_seconds === 'minutes') ? ($second > 0) ?
1666
+                        sprintf('%02d', $second / 60).":".sprintf('%02d', ($second % 60)) : "00:00" : sprintf('%02d', $second);
1667 1667
     }
1668 1668
 
1669 1669
     function array_column($input, $columnKey, $indexKey = null) {
1670 1670
         $array = array();
1671 1671
         foreach ($input as $value) {
1672
-            if (!isset($value[$columnKey])) {
1672
+            if ( ! isset($value[$columnKey])) {
1673 1673
                 trigger_error("Key \"$columnKey\" does not exist in array");
1674 1674
                 return false;
1675 1675
             }
@@ -1677,11 +1677,11 @@  discard block
 block discarded – undo
1677 1677
             if (is_null($indexKey)) {
1678 1678
                 $array[] = $value[$columnKey];
1679 1679
             } else {
1680
-                if (!isset($value[$indexKey])) {
1680
+                if ( ! isset($value[$indexKey])) {
1681 1681
                     trigger_error("Key \"$indexKey\" does not exist in array");
1682 1682
                     return false;
1683 1683
                 }
1684
-                if (!is_scalar($value[$indexKey])) {
1684
+                if ( ! is_scalar($value[$indexKey])) {
1685 1685
                     trigger_error("Key \"$indexKey\" does not contain scalar value");
1686 1686
                     return false;
1687 1687
                 }
@@ -1698,22 +1698,22 @@  discard block
 block discarded – undo
1698 1698
     }
1699 1699
 
1700 1700
     function currency_decimal($amount) {
1701
-		$amount = str_replace( ',', '', $amount );
1701
+		$amount = str_replace(',', '', $amount);
1702 1702
         $decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1703
-        $number_convert = number_format((float) $amount, $decimal_amount, '.', '');
1703
+        $number_convert = number_format((float)$amount, $decimal_amount, '.', '');
1704 1704
         return $number_convert;
1705 1705
     }
1706 1706
 
1707
-    function add_invoice_details($account_arr, $charge_type, $amount,$description) {
1707
+    function add_invoice_details($account_arr, $charge_type, $amount, $description) {
1708 1708
         $accountinfo = $this->CI->session->userdata('accountinfo');
1709 1709
         $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
1710
-        $where = "accountid IN ('" . $reseller_id . "','1')";
1710
+        $where = "accountid IN ('".$reseller_id."','1')";
1711 1711
         $this->CI->db->where($where);
1712 1712
         $this->CI->db->select('*');
1713 1713
         $this->CI->db->order_by('accountid', 'desc');
1714 1714
         $this->CI->db->limit(1);
1715 1715
         $invoiceconf = $this->CI->db->get('invoice_conf');
1716
-        $invoice_conf = (array) $invoiceconf->first_row();
1716
+        $invoice_conf = (array)$invoiceconf->first_row();
1717 1717
         $last_invoiceid = $this->get_invoice_date('invoiceid', '', $account_arr['reseller_id']);
1718 1718
         if ($last_invoiceid && $last_invoiceid > 0) {
1719 1719
             $last_invoiceid = ($last_invoiceid + 1);
@@ -1722,7 +1722,7 @@  discard block
 block discarded – undo
1722 1722
         }
1723 1723
         $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
1724 1724
         $invoice_prefix = $invoice_conf['invoice_prefix'];
1725
-        $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s") . " +" . $invoice_conf['interval'] . " days"));
1725
+        $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
1726 1726
         $invoiceid = $account_arr['posttoexternal'] == 0 ? $this->CI->common_model->generate_receipt($account_arr['id'], $amount, $account_arr, $last_invoiceid, $invoice_prefix, $due_date) : 0;
1727 1727
         
1728 1728
         $insert_arr = array("accountid" => $account_arr['id'],
@@ -1740,111 +1740,111 @@  discard block
 block discarded – undo
1740 1740
     }
1741 1741
     /* ASTPP  3.0  Remove all information related to going to delete customer.
1742 1742
      */
1743
-    function customer_delete_dependencies($id){
1744
-          $this->delete_data('ani_map',array('accountid'=>$id));
1745
-          $this->delete_data('block_patterns',array('accountid'=>$id));
1746
-          $this->delete_data('charge_to_account',array('accountid'=>$id));
1747
-          $this->delete_data('counters',array('accountid'=>$id));
1748
-          $this->delete_data('ip_map',array('accountid'=>$id));
1749
-          $this->delete_data('sip_devices',array('accountid'=>$id));
1750
-          $this->delete_data('speed_dial',array('accountid'=>$id));
1751
-          $this->delete_data('taxes_to_accounts',array('accountid'=>$id));
1752
-          $this->delete_data('mail_details',array('accountid'=>$id));
1753
-          $this->update_data('dids',array("accountid"=>$id),array('accountid'=>0));
1754
-          $this->update_data("accounts",array("id"=>$id),array("deleted"=>1));
1743
+    function customer_delete_dependencies($id) {
1744
+          $this->delete_data('ani_map', array('accountid'=>$id));
1745
+          $this->delete_data('block_patterns', array('accountid'=>$id));
1746
+          $this->delete_data('charge_to_account', array('accountid'=>$id));
1747
+          $this->delete_data('counters', array('accountid'=>$id));
1748
+          $this->delete_data('ip_map', array('accountid'=>$id));
1749
+          $this->delete_data('sip_devices', array('accountid'=>$id));
1750
+          $this->delete_data('speed_dial', array('accountid'=>$id));
1751
+          $this->delete_data('taxes_to_accounts', array('accountid'=>$id));
1752
+          $this->delete_data('mail_details', array('accountid'=>$id));
1753
+          $this->update_data('dids', array("accountid"=>$id), array('accountid'=>0));
1754
+          $this->update_data("accounts", array("id"=>$id), array("deleted"=>1));
1755 1755
     }
1756 1756
     /*
1757 1757
      *  ASTPP  3.0 
1758 1758
      *  Remove all information related to going to delete reseller.
1759 1759
      */
1760
-    function reseller_delete_dependencies($id){
1761
-        $accountinfo=$this->CI->session->userdata('accountinfo');
1762
-        $child_arr=$this->select_data("accounts",array("reseller_id"=>$id,"type"=>0),'id,reseller_id');
1763
-        if($child_arr){
1764
-            foreach($child_arr as $value){
1760
+    function reseller_delete_dependencies($id) {
1761
+        $accountinfo = $this->CI->session->userdata('accountinfo');
1762
+        $child_arr = $this->select_data("accounts", array("reseller_id"=>$id, "type"=>0), 'id,reseller_id');
1763
+        if ($child_arr) {
1764
+            foreach ($child_arr as $value) {
1765 1765
                 $this->customer_delete_dependencies($value['id']);
1766 1766
             }
1767 1767
         }
1768
-        $package_arr=$this->select_data("packages",array("reseller_id"=>$id),'id');
1769
-        if($package_arr){
1770
-            foreach($package_arr as $value){
1771
-                $this->delete_data('package_patterns',array("id"=>$value['id']));
1768
+        $package_arr = $this->select_data("packages", array("reseller_id"=>$id), 'id');
1769
+        if ($package_arr) {
1770
+            foreach ($package_arr as $value) {
1771
+                $this->delete_data('package_patterns', array("id"=>$value['id']));
1772 1772
             }
1773 1773
         }
1774
-        $acc_arr=$this->select_data('accounts',array("id"=>$id),'id,reseller_id');
1775
-        $parent_id=0;
1776
-        if($acc_arr){
1777
-            $parent_id=$acc_arr[0]['reseller_id'];
1774
+        $acc_arr = $this->select_data('accounts', array("id"=>$id), 'id,reseller_id');
1775
+        $parent_id = 0;
1776
+        if ($acc_arr) {
1777
+            $parent_id = $acc_arr[0]['reseller_id'];
1778 1778
         }
1779
-        $pricelist_arr=$this->select_data('pricelists',array('reseller_id'=>$id),'id');
1780
-        if($pricelist_arr){
1781
-             foreach($pricelist_arr as $value){
1782
-                $this->delete_data("routing",array("pricelist_id"=>$value['id']));
1783
-                $this->delete_data("routes",array("pricelist_id"=>$value['id']));
1784
-                $this->update_data('pricelists',array('id'=>$value['id']),array('status'=>2));         
1779
+        $pricelist_arr = $this->select_data('pricelists', array('reseller_id'=>$id), 'id');
1780
+        if ($pricelist_arr) {
1781
+             foreach ($pricelist_arr as $value) {
1782
+                $this->delete_data("routing", array("pricelist_id"=>$value['id']));
1783
+                $this->delete_data("routes", array("pricelist_id"=>$value['id']));
1784
+                $this->update_data('pricelists', array('id'=>$value['id']), array('status'=>2));         
1785 1785
              }
1786 1786
         }
1787
-        $charge_arr=$this->select_data('charges',array('reseller_id'=>$id),'id');
1788
-        if($charge_arr){
1789
-             foreach($charge_arr as $value){
1790
-                $this->delete_data("charge_to_account",array("charge_id"=>$value['id']));
1787
+        $charge_arr = $this->select_data('charges', array('reseller_id'=>$id), 'id');
1788
+        if ($charge_arr) {
1789
+             foreach ($charge_arr as $value) {
1790
+                $this->delete_data("charge_to_account", array("charge_id"=>$value['id']));
1791 1791
              }
1792 1792
         }
1793
-        $this->delete_data('charges',array('reseller_id'=>$id));
1794
-        $this->update_data('dids',array('parent_id'=>$id),array("parent_id"=>$parent_id));
1795
-        $this->delete_data('reseller_pricing',array("reseller_id"=>$id));
1796
-        $this->delete_data('refill_coupon',array("reseller_id"=>$id));
1797
-        $this->delete_data('mail_details',array('accountid'=>$id));
1798
-        $taxes_arr=$this->select_data('taxes',array("reseller_id"=>$id),'id');
1799
-        if($taxes_arr){
1800
-             foreach($taxes_arr as $value){
1801
-                $this->delete_data("taxes_to_accounts",array("taxes_id"=>$value['id']));
1793
+        $this->delete_data('charges', array('reseller_id'=>$id));
1794
+        $this->update_data('dids', array('parent_id'=>$id), array("parent_id"=>$parent_id));
1795
+        $this->delete_data('reseller_pricing', array("reseller_id"=>$id));
1796
+        $this->delete_data('refill_coupon', array("reseller_id"=>$id));
1797
+        $this->delete_data('mail_details', array('accountid'=>$id));
1798
+        $taxes_arr = $this->select_data('taxes', array("reseller_id"=>$id), 'id');
1799
+        if ($taxes_arr) {
1800
+             foreach ($taxes_arr as $value) {
1801
+                $this->delete_data("taxes_to_accounts", array("taxes_id"=>$value['id']));
1802 1802
              }
1803 1803
         }
1804
-        $this->delete_data('taxes',array("reseller_id"=>$id));
1805
-        $this->delete_data('default_templates',array("reseller_id"=>$id));
1806
-        $package_arr=$this->select_data('packages',array('reseller_id'=>$id),'id');
1807
-        if($package_arr){
1808
-            $this->delete_data("counters",array("package_id"=>$value['id']));
1809
-            $this->delete_data("package_patterns",array("package_id"=>$value['id']));
1804
+        $this->delete_data('taxes', array("reseller_id"=>$id));
1805
+        $this->delete_data('default_templates', array("reseller_id"=>$id));
1806
+        $package_arr = $this->select_data('packages', array('reseller_id'=>$id), 'id');
1807
+        if ($package_arr) {
1808
+            $this->delete_data("counters", array("package_id"=>$value['id']));
1809
+            $this->delete_data("package_patterns", array("package_id"=>$value['id']));
1810 1810
         }
1811
-        $this->delete_data('invoice_conf',array('accountid'=>$id));
1812
-        $this->delete_data('packages',array("reseller_id"=>$id));
1813
-        $this->update_data('accounts',array("id"=>$id),array("deleted"=>1));
1811
+        $this->delete_data('invoice_conf', array('accountid'=>$id));
1812
+        $this->delete_data('packages', array("reseller_id"=>$id));
1813
+        $this->update_data('accounts', array("id"=>$id), array("deleted"=>1));
1814 1814
     }
1815 1815
     function subreseller_list($parent_id = '') {
1816 1816
         $customer_id = $parent_id;
1817 1817
         $this->reseller_delete_dependencies($parent_id);
1818
-        $query = 'select id,type from accounts where reseller_id = ' . $parent_id .' AND deleted =0';
1818
+        $query = 'select id,type from accounts where reseller_id = '.$parent_id.' AND deleted =0';
1819 1819
         $result = $this->CI->db->query($query);
1820 1820
         if ($result->num_rows() > 0) {
1821 1821
             $result = $result->result_array();
1822 1822
             foreach ($result as $data) {
1823
-	      if($data['type']==1){
1823
+	      if ($data['type'] == 1) {
1824 1824
 		  $this->reseller_delete_dependencies($data['id']);
1825 1825
 		  $this->subreseller_list($data['id']);
1826
-	      }else{
1826
+	      } else {
1827 1827
 		  $this->customer_delete_dependencies($data['id']);
1828 1828
 	      }
1829 1829
             }
1830 1830
         }
1831 1831
     }
1832 1832
     
1833
-    function delete_data($table_name,$where_arr){
1833
+    function delete_data($table_name, $where_arr) {
1834 1834
         $this->CI->db->where($where_arr);
1835 1835
         $this->CI->db->delete($table_name);
1836 1836
     }
1837
-    function update_data($table_name,$where_arr,$update_arr){
1837
+    function update_data($table_name, $where_arr, $update_arr) {
1838 1838
         $this->CI->db->where($where_arr);
1839
-        $this->CI->db->update($table_name,$update_arr);
1839
+        $this->CI->db->update($table_name, $update_arr);
1840 1840
     }
1841
-    function select_data($table_name,$where_arr,$select){
1841
+    function select_data($table_name, $where_arr, $select) {
1842 1842
         $this->CI->db->where($where_arr);
1843 1843
         $this->CI->db->select($select);
1844
-        $result=$this->CI->db->get($table_name);
1845
-        if($result->num_rows() > 0){
1844
+        $result = $this->CI->db->get($table_name);
1845
+        if ($result->num_rows() > 0) {
1846 1846
             return $result->result_array();
1847
-        }else{
1847
+        } else {
1848 1848
             return false;
1849 1849
         }
1850 1850
     }
@@ -1856,82 +1856,82 @@  discard block
 block discarded – undo
1856 1856
     function get_call_waiting($select = "", $table = "", $status) {
1857 1857
         return ($status == 0) ? "Enable" : "Disable";
1858 1858
 	}
1859
-  function set_invoice_details($select= ''){
1859
+  function set_invoice_details($select = '') {
1860 1860
         $status_array = array("invoice_select" => "--Select--",
1861 1861
             "invoice_inactive" => "Deleted Invoices",
1862 1862
             "invoice_active" => "All Invoices",
1863 1863
         );
1864 1864
         return $status_array;
1865 1865
 }
1866
-function get_invoice_template($invoicedata,$accountdata,$flag){
1866
+function get_invoice_template($invoicedata, $accountdata, $flag) {
1867 1867
       $login_info = $this->CI->session->userdata('accountinfo');
1868 1868
 
1869 1869
       $invoice_config = $this->CI->db_model->getSelect("*", "invoice_conf", array('accountid'=>$login_info['id']));
1870
-      $invoice_config= $invoice_config->result_array();
1871
-      $invoice_config_res= $invoice_config[0];
1870
+      $invoice_config = $invoice_config->result_array();
1871
+      $invoice_config_res = $invoice_config[0];
1872 1872
 
1873 1873
       $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $accountdata["currency_id"]);
1874 1874
       $accountdata["country"] = $this->get_field_name('country', 'countrycode', $accountdata["country_id"]);
1875 1875
       $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
1876
-      if($login_info['type'] == -1){
1876
+      if ($login_info['type'] == -1) {
1877 1877
           $currency = $data["to_currency"];
1878
-      }elseif($login_info['type'] == 1){
1878
+      }elseif ($login_info['type'] == 1) {
1879 1879
 	  $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $login_info["currency_id"]);
1880 1880
           $currency = $accountdata["currency_id"];
1881
-      }else{
1881
+      } else {
1882 1882
           $currency = $accountdata["currency_id"];
1883 1883
       }
1884
-      $decimal_amount=Common_model::$global_config['system_config']['decimalpoints'];
1884
+      $decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1885 1885
       ob_start();
1886 1886
       $this->CI->load->library('/html2pdf/html2pdf');
1887
-      $this->CI->html2pdf = new HTML2PDF('P','A4','en');
1887
+      $this->CI->html2pdf = new HTML2PDF('P', 'A4', 'en');
1888 1888
       $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
1889
-      $template_config=$this->CI->config->item('invoice_template');
1889
+      $template_config = $this->CI->config->item('invoice_template');
1890 1890
       include($template_config.'invoice_template.php');
1891 1891
       $content = ob_get_clean();
1892 1892
       ob_clean();
1893 1893
 
1894 1894
 	$ACCOUNTADD = '';
1895
-	$ACCOUNTADD_CUSTOMER ='';
1895
+	$ACCOUNTADD_CUSTOMER = '';
1896 1896
 	$ACCOUNTADD_RIGHT = '';
1897 1897
 	$ACCOUNT_DESCRIPTION = '';
1898 1898
 	$ACCOUNT_CDRS = '';
1899
-	$ACCOUNT_TOTAL= '';
1899
+	$ACCOUNT_TOTAL = '';
1900 1900
 	$ACCOUNT_TOTAL_FINAL = '';
1901 1901
 	$ACCOUNT_FINAL = '';
1902
-	$CHARGE_ACCOUNT ='';
1902
+	$CHARGE_ACCOUNT = '';
1903 1903
 	$service_info = '';
1904 1904
 	$TotalChrg = "0.00";
1905 1905
 	$NETAMT = "0.00";
1906 1906
 	$TAXAMT = "0.00";
1907
-	$total_sum=0;
1908
-	$total_vat=0;
1907
+	$total_sum = 0;
1908
+	$total_vat = 0;
1909 1909
 	$fromdate = strtotime($invoicedata['from_date']);
1910
-	$from_date =date("Y-m-d",$fromdate);
1910
+	$from_date = date("Y-m-d", $fromdate);
1911 1911
 	$duedate = strtotime($invoicedata['due_date']);
1912
-	$due_date =date("Y-m-d",$duedate);
1912
+	$due_date = date("Y-m-d", $duedate);
1913 1913
 
1914 1914
 /*************************** Company Address Code START ***************************************************/
1915 1915
         $ACCOUNTADD .= '<tr>';
1916 1916
         $ACCOUNTADD .= '<td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;"><b>'.$invoice_config_res['company_name'].'</b></td>';
1917 1917
         $ACCOUNTADD .= '</tr>';
1918
-	if ( $invoice_config_res['address'] != ""){
1918
+	if ($invoice_config_res['address'] != "") {
1919 1919
 
1920 1920
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['address'].'</td></tr>';
1921 1921
     }
1922
-	if ( $invoice_config_res['city'] != ""){
1922
+	if ($invoice_config_res['city'] != "") {
1923 1923
 
1924 1924
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['city'].'</td></tr>';
1925 1925
     }
1926
-	if ( $invoice_config_res['province'] != ""){
1926
+	if ($invoice_config_res['province'] != "") {
1927 1927
 
1928 1928
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['province'].'</td></tr>';
1929 1929
     }
1930
-	if ( $invoice_config_res['country'] != ""){
1930
+	if ($invoice_config_res['country'] != "") {
1931 1931
 
1932 1932
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['country'].'</td></tr>';
1933 1933
     }
1934
-	if ( $invoice_config_res['zipcode'] != ""){
1934
+	if ($invoice_config_res['zipcode'] != "") {
1935 1935
 
1936 1936
         $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['zipcode'].'</td></tr>';
1937 1937
     }
@@ -1942,27 +1942,27 @@  discard block
 block discarded – undo
1942 1942
         $ACCOUNTADD_CUSTOMER .= '<table><tr>';
1943 1943
         $ACCOUNTADD_CUSTOMER .= '<td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;"><b>'.$accountdata['company_name'].'</b></td></tr>';
1944 1944
 
1945
-	if ( $accountdata['address_1'] != ""){
1945
+	if ($accountdata['address_1'] != "") {
1946 1946
 
1947 1947
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['address_1'].'</td></tr>';
1948 1948
     }
1949
-	if ( $accountdata['city'] != ""){
1949
+	if ($accountdata['city'] != "") {
1950 1950
 
1951 1951
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['city'].'</td></tr>';
1952 1952
     }
1953
-	if ( $accountdata['province'] != ""){
1953
+	if ($accountdata['province'] != "") {
1954 1954
 
1955 1955
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['province'].'</td></tr>';
1956 1956
     }
1957
-	if ( $accountdata['country'] != ""){
1957
+	if ($accountdata['country'] != "") {
1958 1958
 
1959 1959
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['country'].'</td></tr>';
1960 1960
     }
1961
-	if ( $accountdata['postal_code'] != ""){
1961
+	if ($accountdata['postal_code'] != "") {
1962 1962
 
1963 1963
         $ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['postal_code'].'</td></tr>';
1964 1964
     }
1965
-    $ACCOUNTADD_CUSTOMER .="</table>"; 
1965
+    $ACCOUNTADD_CUSTOMER .= "</table>"; 
1966 1966
 /*************************** Customer Address Code END ***************************************************/
1967 1967
 
1968 1968
 
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Date</td>';
1973 1973
         $ACCOUNT_DESCRIPTION .= '<td  style="width:40%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Description</td>';
1974 1974
         $ACCOUNT_DESCRIPTION .= '<td  style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Charge Type</td>';
1975
-	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency .')</td>';
1975
+	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency.')</td>';
1976 1976
         $ACCOUNT_DESCRIPTION .= '</tr>';
1977 1977
 
1978 1978
 
@@ -1980,23 +1980,23 @@  discard block
 block discarded – undo
1980 1980
 	$ACCOUNT_CDRS .= '<td style="width:40%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Description</td>';
1981 1981
 	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Duration (Seconds)</td>';
1982 1982
         $ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Total Calls</td>';
1983
-	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency .')</td>';
1983
+	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency.')</td>';
1984 1984
         $ACCOUNT_CDRS .= '</tr>';
1985 1985
 
1986 1986
 	/*** manual invoice **/
1987
-	$this->CI->db->where('item_type <>','INVPAY');
1988
-        $invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details',array("invoiceid"=> $invoicedata['id'],'item_type <>'=> 'TAX' ));
1989
-	$invoice_details= $invoice_details->result_array();
1990
-	$total_sum=0;
1991
-	foreach($invoice_details as $charge_res){
1992
-	    if($charge_res['item_type'] == 'DIDCHRG' || $charge_res['item_type'] == 'SUBCHRG' || $charge_res['item_type'] == 'manual_inv' ){
1993
-		if($charge_res['item_type'] == 'manual_inv'){
1987
+	$this->CI->db->where('item_type <>', 'INVPAY');
1988
+        $invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details', array("invoiceid"=> $invoicedata['id'], 'item_type <>'=> 'TAX'));
1989
+	$invoice_details = $invoice_details->result_array();
1990
+	$total_sum = 0;
1991
+	foreach ($invoice_details as $charge_res) {
1992
+	    if ($charge_res['item_type'] == 'DIDCHRG' || $charge_res['item_type'] == 'SUBCHRG' || $charge_res['item_type'] == 'manual_inv') {
1993
+		if ($charge_res['item_type'] == 'manual_inv') {
1994 1994
 			$charge_res['item_type'] = 'Manual Invoice';
1995 1995
 		}
1996
-		if($charge_res['item_type'] == 'DIDCHRG'){
1996
+		if ($charge_res['item_type'] == 'DIDCHRG') {
1997 1997
 			$charge_res['item_type'] = 'DID Charge';
1998 1998
 		}
1999
-		if($charge_res['item_type'] == 'SUBCHRG'){
1999
+		if ($charge_res['item_type'] == 'SUBCHRG') {
2000 2000
 			$charge_res['item_type'] = 'Subscription Charge';
2001 2001
 		}
2002 2002
 
@@ -2007,12 +2007,12 @@  discard block
 block discarded – undo
2007 2007
 
2008 2008
 		$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($this->CI->common_model->calculate_currency($charge_res['debit'])).'</td>';
2009 2009
 		$ACCOUNT_DESCRIPTION .= '</tr>';
2010
-	     }else{
2011
-            $cdrs_data = $this->CI->db_model->getSelect("sum(billseconds) as billseconds,count(*) as count", "cdrs", array("accountid" => $charge_res['accountid'],"calltype" => $charge_res['item_type']));
2010
+	     } else {
2011
+            $cdrs_data = $this->CI->db_model->getSelect("sum(billseconds) as billseconds,count(*) as count", "cdrs", array("accountid" => $charge_res['accountid'], "calltype" => $charge_res['item_type']));
2012 2012
             $cdrs_result = $cdrs_data->result_array();
2013
-	    if($cdrs_result[0]['count'] > 0 ){
2014
-		$cdrs_record_count=$cdrs_result[0]['count'] ;
2015
-		$cdrs_record_billseconds=$cdrs_result[0]['billseconds'] ;
2013
+	    if ($cdrs_result[0]['count'] > 0) {
2014
+		$cdrs_record_count = $cdrs_result[0]['count'];
2015
+		$cdrs_record_billseconds = $cdrs_result[0]['billseconds'];
2016 2016
 /*echo '<pre>'.$cdrs_record_count;
2017 2017
 print_r($cdrs_result);
2018 2018
 exit;*/
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
 
2031 2031
 /**********************************Tax Apply Start********************************************************************/
2032 2032
 	$total_sum = $total_sum;
2033
-	$total_sum=$this->currency_decimal($this->CI->common_model->calculate_currency($total_sum));
2034
-        $invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details',array("invoiceid"=> $invoicedata['id'],'item_type '=> 'TAX'));
2033
+	$total_sum = $this->currency_decimal($this->CI->common_model->calculate_currency($total_sum));
2034
+        $invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details', array("invoiceid"=> $invoicedata['id'], 'item_type '=> 'TAX'));
2035 2035
  	//$ACCOUNT_TOTAL .= '<td><table style="width:100%;margin-left:360px;">';
2036 2036
 
2037 2037
 	$ACCOUNT_TOTAL .= '<tr>';
@@ -2041,35 +2041,35 @@  discard block
 block discarded – undo
2041 2041
 //	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$total_sum .'</td>';
2042 2042
         $ACCOUNT_TOTAL .= '</tr>';
2043 2043
 
2044
-	if($invoice_tax->num_rows() > 0 ){
2045
-	   foreach($invoice_tax->result_array() as $invoice_tax){
2044
+	if ($invoice_tax->num_rows() > 0) {
2045
+	   foreach ($invoice_tax->result_array() as $invoice_tax) {
2046 2046
 
2047
-		$total_vat +=$invoice_tax['debit'];
2047
+		$total_vat += $invoice_tax['debit'];
2048 2048
 		$ACCOUNT_TOTAL .= '<tr>';
2049 2049
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;"></td>';
2050 2050
 		$ACCOUNT_TOTAL .= '<td style="width:40%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;"></td>';
2051 2051
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"><b>'.$invoice_tax["description"].':</b></td>';
2052
-		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($this->CI->common_model->calculate_currency($total_vat)) .'</td>';
2052
+		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($this->CI->common_model->calculate_currency($total_vat)).'</td>';
2053 2053
 		$ACCOUNT_TOTAL .= '</tr>';
2054 2054
 
2055 2055
 	   }
2056
-		$total_vat=$this->currency_decimal($this->CI->common_model->calculate_currency($total_vat));	
2057
-	}else{
2056
+		$total_vat = $this->currency_decimal($this->CI->common_model->calculate_currency($total_vat));	
2057
+	} else {
2058 2058
 /********harsh_308***********/
2059 2059
 		$ACCOUNT_TOTAL .= '<tr>';
2060 2060
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2061 2061
 		$ACCOUNT_TOTAL .= '<td style="width:40%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2062 2062
 		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"><b>Total TAX:</b></td>';
2063
-		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($total_vat) .'</td>';
2063
+		$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($total_vat).'</td>';
2064 2064
 		$ACCOUNT_TOTAL .= '</tr>';
2065 2065
 
2066 2066
 	}
2067
-	$sub_total=$total_sum+$total_vat;
2067
+	$sub_total = $total_sum + $total_vat;
2068 2068
 	$ACCOUNT_TOTAL .= '<tr>';
2069 2069
 	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2070 2070
 	$ACCOUNT_TOTAL .= '<td style="width:40%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"></td>';
2071 2071
 	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;"><b>Sub Total:</b></td>';
2072
-	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($sub_total) .'</td>';
2072
+	$ACCOUNT_TOTAL .= '<td style="width:20%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;text-align:right;">'.$this->currency_decimal($sub_total).'</td>';
2073 2073
 	$ACCOUNT_TOTAL .= '</tr>';
2074 2074
 
2075 2075
 
@@ -2098,26 +2098,26 @@  discard block
 block discarded – undo
2098 2098
 
2099 2099
 /*************************** Invoice Note Code END ***************************************************/
2100 2100
         $invoice_notes = $this->CI->db_model->getSelect('*', 'invoices', array('id'=>$invoicedata['id']));
2101
-        $invoice_notes=$invoice_notes->result_array();
2102
-	if(isset($invoice_notes[0]['notes'])){
2103
-		$invoice_notes=$invoice_notes[0]['notes'];
2104
-	}else{
2105
-		if($invoice_notes[0]['invoice_note'] == '0' ){
2106
-			$invoice_notes='THIS IS A 30 DAY ACCOUNT, SO PLEASE MAKE PAYMENT WITHIN THESE TERMS';
2107
-		}else{
2108
-			$invoice_notes=$invoice_notes[0]['invoice_note'];
2101
+        $invoice_notes = $invoice_notes->result_array();
2102
+	if (isset($invoice_notes[0]['notes'])) {
2103
+		$invoice_notes = $invoice_notes[0]['notes'];
2104
+	} else {
2105
+		if ($invoice_notes[0]['invoice_note'] == '0') {
2106
+			$invoice_notes = 'THIS IS A 30 DAY ACCOUNT, SO PLEASE MAKE PAYMENT WITHIN THESE TERMS';
2107
+		} else {
2108
+			$invoice_notes = $invoice_notes[0]['invoice_note'];
2109 2109
 		}
2110 2110
 	}
2111 2111
 /*************************** Invoice Note Code END ***************************************************/
2112 2112
 
2113 2113
 	if (file_exists(getcwd()."/upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'])) {
2114
-		if($invoice_config[0]['logo'] != ''){
2115
-			$content = str_replace("<LOGO>",base_url()."upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'],$content);
2116
-		}else{
2117
-			$content = str_replace("<LOGO>",base_url().'/assets/images/logo.png',$content);
2114
+		if ($invoice_config[0]['logo'] != '') {
2115
+			$content = str_replace("<LOGO>", base_url()."upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'], $content);
2116
+		} else {
2117
+			$content = str_replace("<LOGO>", base_url().'/assets/images/logo.png', $content);
2118 2118
 		}
2119
-	}else{
2120
-		$content = str_replace("<LOGO>",base_url().'/assets/images/logo.png',$content);
2119
+	} else {
2120
+		$content = str_replace("<LOGO>", base_url().'/assets/images/logo.png', $content);
2121 2121
 	}
2122 2122
 
2123 2123
 	$ACCOUNT_TOTAL_FINAL .= '<tr>';
@@ -2126,37 +2126,37 @@  discard block
 block discarded – undo
2126 2126
 	$ACCOUNT_TOTAL_FINAL .= '</tr>';
2127 2127
 
2128 2128
       //  $content = str_replace("<LOGO>",$image_logo,$content);   
2129
-        $content = str_replace("<ACCOUNTADD>",$ACCOUNTADD,$content);
2130
-        $content = str_replace("<ACCOUNTADD_CUSTOMER>",$ACCOUNTADD_CUSTOMER,$content);
2131
-        $content = str_replace("<ACCOUNTADD_RIGHT>",$ACCOUNTADD_RIGHT,$content);
2132
-	$content = str_replace("<ACCOUNT_DESCRIPTION>",$ACCOUNT_DESCRIPTION,$content);
2133
-	$content = str_replace("<ACCOUNT_CDRS>",$ACCOUNT_CDRS,$content);
2134
-	$content = str_replace("<ACCOUNT_TOTAL>",$ACCOUNT_TOTAL,$content);
2135
-	$content = str_replace("<ACCOUNT_TOTAL_FINAL>",$ACCOUNT_TOTAL_FINAL,$content);
2136
-        $content = str_replace("<NOTES>",$invoice_notes,$content);
2129
+        $content = str_replace("<ACCOUNTADD>", $ACCOUNTADD, $content);
2130
+        $content = str_replace("<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content);
2131
+        $content = str_replace("<ACCOUNTADD_RIGHT>", $ACCOUNTADD_RIGHT, $content);
2132
+	$content = str_replace("<ACCOUNT_DESCRIPTION>", $ACCOUNT_DESCRIPTION, $content);
2133
+	$content = str_replace("<ACCOUNT_CDRS>", $ACCOUNT_CDRS, $content);
2134
+	$content = str_replace("<ACCOUNT_TOTAL>", $ACCOUNT_TOTAL, $content);
2135
+	$content = str_replace("<ACCOUNT_TOTAL_FINAL>", $ACCOUNT_TOTAL_FINAL, $content);
2136
+        $content = str_replace("<NOTES>", $invoice_notes, $content);
2137 2137
 
2138 2138
 //echo $content; exit;
2139 2139
 
2140
-	$invoice_path=$this->CI->config->item('invoices_path');
2140
+	$invoice_path = $this->CI->config->item('invoices_path');
2141 2141
 	$download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; 
2142 2142
        //echo  $download_path; exit;
2143 2143
        $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
2144 2144
        $this->CI->html2pdf->writeHTML($content);
2145 2145
        
2146
-       if($flag== 'TRUE'){
2146
+       if ($flag == 'TRUE') {
2147 2147
         $download_path = $invoicedata['invoice_prefix'].$invoicedata['invoiceid'].".pdf";
2148 2148
        
2149
-        $this->CI->html2pdf->Output($download_path,"D");        
2150
-       }else{
2149
+        $this->CI->html2pdf->Output($download_path, "D");        
2150
+       } else {
2151 2151
         $current_dir = getcwd()."/invoices/";
2152 2152
         $dir_name = $accountdata["id"];
2153
-        if(!is_dir($current_dir.$dir_name)){
2154
-                mkdir($current_dir.$dir_name,0777, true);
2153
+        if ( ! is_dir($current_dir.$dir_name)) {
2154
+                mkdir($current_dir.$dir_name, 0777, true);
2155 2155
                 chmod($current_dir.$dir_name, 0777);        
2156 2156
         }        
2157
-        $invoice_path=$this->CI->config->item('invoices_path');
2157
+        $invoice_path = $this->CI->config->item('invoices_path');
2158 2158
         $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; 
2159
-        $this->CI->html2pdf->Output($download_path,"F");         
2159
+        $this->CI->html2pdf->Output($download_path, "F");         
2160 2160
        }
2161 2161
 }
2162 2162
     function reseller_select_value($select, $table, $id_where = '') {
@@ -2176,55 +2176,55 @@  discard block
 block discarded – undo
2176 2176
 	   return 'Admin';
2177 2177
     }
2178 2178
     
2179
-    function get_subreseller_info($parent_id){
2180
-        if(!empty($parent_id)){
2181
-	  $str=$parent_id.",";
2182
-        }else{
2183
-          $str=null;
2179
+    function get_subreseller_info($parent_id) {
2180
+        if ( ! empty($parent_id)) {
2181
+	  $str = $parent_id.",";
2182
+        } else {
2183
+          $str = null;
2184 2184
         }
2185 2185
         $query = "select id from accounts where reseller_id = '$parent_id' AND deleted =0 AND type=1";
2186 2186
         $result = $this->CI->db->query($query);
2187
-        if($result->num_rows() > 0){
2187
+        if ($result->num_rows() > 0) {
2188 2188
         $result = $result->result_array();
2189
-	  foreach ($result as $data){
2190
-	    if(!empty($data['id'])){
2191
-	      $str.=$this->get_subreseller_info($data['id']);
2189
+	  foreach ($result as $data) {
2190
+	    if ( ! empty($data['id'])) {
2191
+	      $str .= $this->get_subreseller_info($data['id']);
2192 2192
 	    }
2193 2193
 	  }
2194 2194
 	}
2195 2195
 	return $str;
2196 2196
     }
2197
-    function get_parent_info($child_id,$parent_id){
2198
-        if(!empty($child_id)){
2199
-	  $str=$child_id.",";
2200
-        }else{
2201
-          $str=null;
2197
+    function get_parent_info($child_id, $parent_id) {
2198
+        if ( ! empty($child_id)) {
2199
+	  $str = $child_id.",";
2200
+        } else {
2201
+          $str = null;
2202 2202
         }
2203
-        if($child_id > 0){
2203
+        if ($child_id > 0) {
2204 2204
         $query = "select reseller_id from accounts where id = '$child_id'";
2205 2205
         $result = $this->CI->db->query($query);
2206
-        if($result->num_rows() > 0){
2206
+        if ($result->num_rows() > 0) {
2207 2207
         $parent_info = (array)$result->first_row();
2208
-	  if($parent_info['reseller_id'] != $parent_id){
2209
-	    $str.=$this->get_parent_info($parent_info['reseller_id'],$parent_id);
2208
+	  if ($parent_info['reseller_id'] != $parent_id) {
2209
+	    $str .= $this->get_parent_info($parent_info['reseller_id'], $parent_id);
2210 2210
 	  }
2211 2211
 	}
2212 2212
 	}
2213 2213
 	return $str;
2214 2214
     }
2215
-    function get_did_accountid($select,$table,$where){
2216
-      $accountinfo=$this->CI->session->userdata('accountinfo');
2217
-      $this->CI->db->where('note',$where);
2218
-      $this->CI->db->where('parent_id',$accountinfo['id']);
2215
+    function get_did_accountid($select, $table, $where) {
2216
+      $accountinfo = $this->CI->session->userdata('accountinfo');
2217
+      $this->CI->db->where('note', $where);
2218
+      $this->CI->db->where('parent_id', $accountinfo['id']);
2219 2219
       $this->CI->db->select('reseller_id');
2220
-      $reseller_pricing_result=$this->CI->db->get('reseller_pricing');
2221
-      $account_info=(array)$reseller_pricing_result->first_row();
2222
-      $account_name=$this->get_field_name_coma_new('first_name,last_name,number','accounts',$account_info['reseller_id']);
2220
+      $reseller_pricing_result = $this->CI->db->get('reseller_pricing');
2221
+      $account_info = (array)$reseller_pricing_result->first_row();
2222
+      $account_name = $this->get_field_name_coma_new('first_name,last_name,number', 'accounts', $account_info['reseller_id']);
2223 2223
       return $account_name;     
2224 2224
     }
2225 2225
 
2226
-    function get_status_new($select = "",$table = "",$status = "") {
2227
-      return ($status['status']==0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
2226
+    function get_status_new($select = "", $table = "", $status = "") {
2227
+      return ($status['status'] == 0) ? "<span class='label label-sm label-inverse arrowed-in' title='release'>Active<span>" : "<span class='label label-sm' title='release'>Inactive<span>";
2228 2228
     }
2229 2229
     
2230 2230
 }
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/form.php 1 patch
Spacing   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
 ###############################################################################
23 23
 
24
-if (!defined('BASEPATH'))
24
+if ( ! defined('BASEPATH'))
25 25
     exit('No direct script access allowed');
26 26
 
27 27
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 class Form {
31 31
 
32 32
     protected $CI; // codeigniter
33
-    protected $fields = array();  // array of fields
33
+    protected $fields = array(); // array of fields
34 34
     protected $form_title = 'Form';
35 35
     protected $form_id = 'form';
36 36
     protected $form_action = '';
@@ -58,31 +58,31 @@  discard block
 block discarded – undo
58 58
     function check_permissions() {
59 59
         if ($this->CI->session->userdata('user_login') == TRUE) {
60 60
             $module_info = unserialize($this->CI->session->userdata("permited_modules"));
61
-            if($this->CI->session->userdata('userlevel_logintype')!= 0 && $this->CI->session->userdata('userlevel_logintype')!= 3){
62
-	    $module_info[]='dashboard';
61
+            if ($this->CI->session->userdata('userlevel_logintype') != 0 && $this->CI->session->userdata('userlevel_logintype') != 3) {
62
+	    $module_info[] = 'dashboard';
63 63
             }
64 64
             $url = $this->CI->uri->uri_string;
65 65
             $file_name = explode("/", $url);
66
-            if(isset($file_name['1']) ){
66
+            if (isset($file_name['1'])) {
67 67
 	      $module = explode('_', $file_name['1']);
68
-            }else{
69
-              $module=$file_name;
68
+            } else {
69
+              $module = $file_name;
70 70
             }
71
-            if($this->CI->session->userdata('userlevel_logintype')==1 ){
72
-				$module_info[]='user';
71
+            if ($this->CI->session->userdata('userlevel_logintype') == 1) {
72
+				$module_info[] = 'user';
73 73
 			}
74 74
             if (in_array($module[0], $module_info)) {
75
-                if($this->CI->session->userdata('userlevel_logintype')== 0 && $module[0] == 'customer' && isset($file_name[1]) && $file_name[1] !='customer_transfer'){
76
-                     redirect(base_url() . 'user/user/');
77
-                }else{
75
+                if ($this->CI->session->userdata('userlevel_logintype') == 0 && $module[0] == 'customer' && isset($file_name[1]) && $file_name[1] != 'customer_transfer') {
76
+                     redirect(base_url().'user/user/');
77
+                } else {
78 78
                    return true;
79 79
                 }
80 80
             } else {
81 81
                 $this->CI->session->set_userdata('astpp_errormsg', 'You do not have permission to access this module..!');
82 82
                 if ($this->CI->session->userdata('userlevel_logintype') == '-1' || $this->CI->session->userdata('logintype') == '1') {
83
-                    redirect(base_url() . 'dashboard/');
83
+                    redirect(base_url().'dashboard/');
84 84
                 } else {
85
-                    redirect(base_url() . 'user/user/');
85
+                    redirect(base_url().'user/user/');
86 86
                 }
87 87
             }
88 88
         } else {
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 
93 93
     function build_form($fields_array, $values) {
94 94
         $form_contents = '';
95
-        $form_contents.= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">';
96
-        if(isset($fields_array['breadcrumb'])){
97
-            $form_contents.=form_breadcrumb($fields_array['breadcrumb']);
95
+        $form_contents .= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">';
96
+        if (isset($fields_array['breadcrumb'])) {
97
+            $form_contents .= form_breadcrumb($fields_array['breadcrumb']);
98 98
             unset($fields_array['breadcrumb']);
99 99
         }
100
-        $form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
100
+        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
101 101
         unset($fields_array['forms']);
102 102
         $button_array = array();
103 103
         if (isset($fields_array['button_save']) || isset($fields_array['button_cancel']) || isset($fields_array['additional_button'])) {
@@ -113,76 +113,76 @@  discard block
 block discarded – undo
113 113
             }
114 114
         }
115 115
         if (isset($additiopnal_button)) {
116
-            $form_contents.= form_button(gettext($additiopnal_button));
116
+            $form_contents .= form_button(gettext($additiopnal_button));
117 117
         }
118 118
         $i = 0;
119 119
         foreach ($fields_array as $fieldset_key => $form_fileds) {
120 120
             if (count($fields_array) > 1) {
121 121
                 if ($i == 1 || $i == 3) {
122
-                    $form_contents.= '<div class="col-md-6 no-padding pull-right">';
123
-                    $form_contents.= '<div class="col-md-12 padding-x-4">';
122
+                    $form_contents .= '<div class="col-md-6 no-padding pull-right">';
123
+                    $form_contents .= '<div class="col-md-12 padding-x-4">';
124 124
                 } else {
125
-                    $form_contents.= '<div class="col-md-6 no-padding">';
126
-                    $form_contents.= '<div class="col-md-12 padding-x-4">';
125
+                    $form_contents .= '<div class="col-md-6 no-padding">';
126
+                    $form_contents .= '<div class="col-md-12 padding-x-4">';
127 127
                 }
128 128
             } else {
129
-               $form_contents.= '<div class="col-md-12 no-padding">';
130
-                $form_contents.= '<div class="col-md-12 no-padding">';
129
+               $form_contents .= '<div class="col-md-12 no-padding">';
130
+                $form_contents .= '<div class="col-md-12 no-padding">';
131 131
             }
132
-            $form_contents.= '<ul class="no-padding">';
133
-                $form_contents.= '<div class="col-md-12 no-padding">';
132
+            $form_contents .= '<ul class="no-padding">';
133
+                $form_contents .= '<div class="col-md-12 no-padding">';
134 134
             if ($i == 1 || $i == 3) {
135
-                $form_contents.= form_fieldset(gettext($fieldset_key));
135
+                $form_contents .= form_fieldset(gettext($fieldset_key));
136 136
             } else {
137
-                $form_contents.= form_fieldset(gettext($fieldset_key));
137
+                $form_contents .= form_fieldset(gettext($fieldset_key));
138 138
             }
139 139
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
140
-                $form_contents.= '<li class="col-md-12">';
140
+                $form_contents .= '<li class="col-md-12">';
141 141
                 if ($fieldvalue[1] == 'HIDDEN') {
142 142
                     if (isset($this->CI->input->post))
143
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
143
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
144 144
                     else
145
-                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : ''):(isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] :'');
146
-                    $form_contents.= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
147
-                }else {
148
-		      $validation_arr=array();
149
-		      if($fieldvalue[1]=='INPUT'){
150
-		        if(!empty($fieldvalue[3])){
151
-		          $validation_arr=explode("|",$fieldvalue[3]);
145
+                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
146
+                    $form_contents .= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
147
+                } else {
148
+		      $validation_arr = array();
149
+		      if ($fieldvalue[1] == 'INPUT') {
150
+		        if ( ! empty($fieldvalue[3])) {
151
+		          $validation_arr = explode("|", $fieldvalue[3]);
152 152
 		        }
153 153
 		      }
154
-		      elseif($fieldvalue[2]=='SELECT'){
154
+		      elseif ($fieldvalue[2] == 'SELECT') {
155 155
 
156
-		        if(is_array($fieldvalue[4])){
157
-		          $validation_arr=explode("|",$fieldvalue[4]['rules']);
158
-		        }else{
159
-		        $validation_arr=explode("|",$fieldvalue[4]);
156
+		        if (is_array($fieldvalue[4])) {
157
+		          $validation_arr = explode("|", $fieldvalue[4]['rules']);
158
+		        } else {
159
+		        $validation_arr = explode("|", $fieldvalue[4]);
160 160
 		        }
161 161
 		      }
162
-		      if(!empty($validation_arr)){
163
-		      $fieldvalue[0] = in_array('required',$validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
164
-		      $fieldvalue[0] = in_array('dropdown',$validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
162
+		      if ( ! empty($validation_arr)) {
163
+		      $fieldvalue[0] = in_array('required', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
164
+		      $fieldvalue[0] = in_array('dropdown', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
165 165
 		      }
166 166
  
167 167
                     if (is_array($fieldvalue[1]) || (is_array($fieldvalue[2]) && isset($fieldvalue[2]['hidden']))) {
168
-                        $form_contents.= form_label(gettext($fieldvalue[0]), $fieldvalue[0], array('class' => 'col-md-3 no-padding add_settings'));
168
+                        $form_contents .= form_label(gettext($fieldvalue[0]), $fieldvalue[0], array('class' => 'col-md-3 no-padding add_settings'));
169 169
                     } else {
170
-                        $form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "col-md-3 no-padding"));
170
+                        $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "col-md-3 no-padding"));
171 171
                     }
172 172
                 }
173
-                if ($fieldvalue[2] == 'SELECT' && !isset($fieldvalue[13])) {
173
+                if ($fieldvalue[2] == 'SELECT' && ! isset($fieldvalue[13])) {
174 174
 
175 175
                 /*
176 176
                  To make Drop down enabled disabled
177 177
                 */
178
-                 $extra =isset($fieldvalue[1]['extra']) ? $fieldvalue[1]['extra'] :'';
178
+                 $extra = isset($fieldvalue[1]['extra']) ? $fieldvalue[1]['extra'] : '';
179 179
                  /***************************/
180 180
                     if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
181
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
181
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
182 182
 
183
-                        if (isset($this->CI->input->post)){
184
-                            $fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
185
-                        }else{
183
+                        if (isset($this->CI->input->post)) {
184
+                            $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
185
+                        } else {
186 186
                             if (is_array($fieldvalue[1])) {
187 187
                                 $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
188 188
                             } else {
@@ -191,38 +191,38 @@  discard block
 block discarded – undo
191 191
                         }
192 192
                         $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
193 193
 
194
-                        if ($fieldset_key ==  gettext('System Configuration Information') || ($fieldset_key == 'Billing Information'  && $fieldvalue[0] == 'Force Trunk') || ($fieldset_key == 'Card Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Account') || $fieldset_key == 'Freeswitch Devices' && $fieldvalue[0] == 'Rate Group' || ($fieldset_key== 'Origination Rate Add/Edit' && $fieldvalue[0] == 'Trunks' )||$fieldset_key== 'Billing Information' && $fieldvalue[0] == 'Rate Group'  || ($fieldset_key== 'Information' && $fieldvalue[0] == 'Failover GW Name #1') || ($fieldset_key== 'Information' && $fieldvalue[0] == 'Failover GW Name #2') || ($fieldset_key== 'Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key== 'Sip Devices' && $fieldvalue[0] == 'Sip Profile') || ($fieldset_key== 'Sip Devices' && $fieldvalue[0] == 'Account')) {
195
-                            $form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
194
+                        if ($fieldset_key == gettext('System Configuration Information') || ($fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Force Trunk') || ($fieldset_key == 'Card Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Account') || $fieldset_key == 'Freeswitch Devices' && $fieldvalue[0] == 'Rate Group' || ($fieldset_key == 'Origination Rate Add/Edit' && $fieldvalue[0] == 'Trunks') || $fieldset_key == 'Billing Information' && $fieldvalue[0] == 'Rate Group' || ($fieldset_key == 'Information' && $fieldvalue[0] == 'Failover GW Name #1') || ($fieldset_key == 'Information' && $fieldvalue[0] == 'Failover GW Name #2') || ($fieldset_key == 'Information' && $fieldvalue[0] == 'Rate Group') || ($fieldset_key == 'Sip Devices' && $fieldvalue[0] == 'Sip Profile') || ($fieldset_key == 'Sip Devices' && $fieldvalue[0] == 'Account')) {
195
+                            $form_contents .= form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
196 196
                         } else {
197
-                            $form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
197
+                            $form_contents .= form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
198 198
                         }
199
-			            if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
200
-                        	if(is_array($fieldvalue[4])){
199
+			            if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
200
+                        	if (is_array($fieldvalue[4])) {
201 201
 								
202
-								if(isset($fieldvalue[1]['name'])){
203
-									$fieldvalue_pass=$fieldvalue[1]['name'];
204
-								}else{
205
-									$fieldvalue_pass=$fieldvalue[1];
202
+								if (isset($fieldvalue[1]['name'])) {
203
+									$fieldvalue_pass = $fieldvalue[1]['name'];
204
+								} else {
205
+									$fieldvalue_pass = $fieldvalue[1];
206 206
 								}
207 207
 								
208 208
         				        $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]['rules']);
209
-        				    }else{
209
+        				    } else {
210 210
 								
211
-								if(isset($fieldvalue[1]['name'])){
212
-									$fieldvalue_pass=$fieldvalue[1]['name'];
213
-								}else{
214
-									$fieldvalue_pass=$fieldvalue[1];
211
+								if (isset($fieldvalue[1]['name'])) {
212
+									$fieldvalue_pass = $fieldvalue[1]['name'];
213
+								} else {
214
+									$fieldvalue_pass = $fieldvalue[1];
215 215
 								}
216 216
 								
217 217
         				       $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]);
218 218
         				    }   
219 219
                         }
220
-                        $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
221
-                        $form_contents.= '<span class="popup_error error  no-padding" id="'.(gettext(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1])).'_error">
220
+                        $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
221
+                        $form_contents .= '<span class="popup_error error  no-padding" id="'.(gettext(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1])).'_error">
222 222
                         </span></div>';                         
223 223
                     } else {
224 224
                         if (isset($this->CI->input->post)) {
225
-                            $fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
225
+                            $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
226 226
                         } else {
227 227
                             if (is_array($fieldvalue[1])) {
228 228
                                 $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
@@ -231,53 +231,53 @@  discard block
 block discarded – undo
231 231
                             }
232 232
                         }
233 233
 
234
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
234
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
235 235
                         $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
236
-                        $form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
237
-                        if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
236
+                        $form_contents .= form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
237
+                        if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
238 238
 			  $this->CI->form_validation->set_rules($fieldvalue[1], $fieldvalue[0], $fieldvalue[4]);
239 239
                         }
240
-                        $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
241
-                        $form_contents.= '<span class="popup_error error  no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error">
240
+                        $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
241
+                        $form_contents .= '<span class="popup_error error  no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error">
242 242
                         </span></div>';                        
243 243
                     }
244 244
                 } else if (isset($fieldvalue[13]) && $fieldvalue[13] != '') {
245 245
 
246 246
                     /* For multi select code */
247
-                    $str = $fieldvalue[7] . "," . $fieldvalue[8];
247
+                    $str = $fieldvalue[7].",".$fieldvalue[8];
248 248
 
249 249
                     if (isset($this->CI->input->post))
250
-                        $fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
250
+                        $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
251 251
                     else
252 252
                         $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
253 253
 
254 254
                     $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
255 255
                     if ($fieldset_key === 'System Configuration Information') {
256
-                        $form_contents.=form_dropdown_multiselect($fieldvalue[1], $drp_array, '');
256
+                        $form_contents .= form_dropdown_multiselect($fieldvalue[1], $drp_array, '');
257 257
                     } else {
258
-                        $form_contents.=form_dropdown_multiselect($fieldvalue[1] . "[]", $drp_array, $fieldvalue['value']);
258
+                        $form_contents .= form_dropdown_multiselect($fieldvalue[1]."[]", $drp_array, $fieldvalue['value']);
259 259
                     }
260
-                    if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
260
+                    if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
261 261
 			$this->CI->form_validation->set_rules($fieldvalue[1], $fieldvalue[0], $fieldvalue[4]);
262 262
                     }
263
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[1].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
264
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[1].'_error"></span></div>';                   
263
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[1].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
264
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[1].'_error"></span></div>';                   
265 265
                     /* End---------------------   For multi select code */
266 266
                 } else if ($fieldvalue[1] == 'INPUT') {
267 267
 
268 268
 
269 269
                     if (isset($this->CI->input->post))
270
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
271
-                    else{
272
-                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : ''):(isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] :'');
270
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
271
+                    else {
272
+                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
273 273
                     }    
274
-                    $form_contents.= form_input($fieldvalue[2], 'readonly');
275
-                    if(isset($fieldvalue[6]) && !empty($fieldvalue[6])){
276
-                        $form_contents.=$fieldvalue[6];
274
+                    $form_contents .= form_input($fieldvalue[2], 'readonly');
275
+                    if (isset($fieldvalue[6]) && ! empty($fieldvalue[6])) {
276
+                        $form_contents .= $fieldvalue[6];
277 277
                     }    
278 278
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
279
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
280
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
279
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
280
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
281 281
                     </span></div>';
282 282
                 }
283 283
                 /* 
@@ -285,98 +285,98 @@  discard block
 block discarded – undo
285 285
                  */
286 286
                 else if ($fieldvalue[1] == 'IMAGE') {
287 287
                     if (isset($this->CI->input->post))
288
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
288
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
289 289
                        
290 290
                     else
291 291
                         $fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
292 292
                         $fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
293
-                    $form_contents.= form_image($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
294
-                    	 $form_contents.=@$fieldvalue[6];
293
+                    $form_contents .= form_image($fieldvalue[2], 'readonly', $fieldvalue[2]['style']);
294
+                    	 $form_contents .= @$fieldvalue[6];
295 295
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
296
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
297
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
296
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
297
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
298 298
                     </span></div>';
299 299
                 }
300 300
                 else if ($fieldvalue[1] == 'DEL_BUTTON') {
301 301
                     if (isset($this->CI->input->post))
302
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
302
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
303 303
                        
304 304
                     else
305 305
                         $fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
306 306
                         $fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
307
-                    $form_contents.= form_img_delete($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
308
-                    	 $form_contents.=@$fieldvalue[6];
307
+                    $form_contents .= form_img_delete($fieldvalue[2], 'readonly', $fieldvalue[2]['style']);
308
+                    	 $form_contents .= @$fieldvalue[6];
309 309
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
310
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
311
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
310
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
311
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
312 312
                     </span></div>';
313 313
                 }
314 314
                 /**********************************************************************************/
315 315
                 else if ($fieldvalue[1] == 'PASSWORD') {
316 316
                     if (isset($this->CI->input->post))
317
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
317
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
318 318
                     else
319
-                        $fieldvalue[2]['value'] = ($values) ?@$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
320
-                    $form_contents.= form_password($fieldvalue[2]);
319
+                        $fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
320
+                    $form_contents .= form_password($fieldvalue[2]);
321 321
                     $this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
322
-                    $form_contents.= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
323
-                    $form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
322
+                    $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue[2]['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>';
323
+                    $form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
324 324
                     </span></div>';
325 325
                 } else if ($fieldvalue[2] == 'CHECKBOX') {
326 326
                     $OptionArray = array();
327 327
 
328
-					if(isset($fieldvalue[7]) && $fieldvalue[7] != '')
328
+					if (isset($fieldvalue[7]) && $fieldvalue[7] != '')
329 329
 					$OptionArray = call_user_func_array(array($this->CI->common, $fieldvalue[7]), array($fieldvalue[6]));
330
-                    if (isset($this->CI->input->post)){
331
-                        $fieldvalue[3]['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
330
+                    if (isset($this->CI->input->post)) {
331
+                        $fieldvalue[3]['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
332 332
                     }    
333 333
                     else
334 334
                     {
335
-                        $fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1: 0) : @$fieldvalue[3]['value'];
335
+                        $fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1 : 0) : @$fieldvalue[3]['value'];
336 336
 					}
337 337
                     if ($fieldvalue[3]['value'] == "1") {
338 338
                         $checked = true;
339 339
                     } else {
340 340
                         $checked = false;
341 341
                     };
342
-                    if(isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != ""){
342
+                    if (isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != "") {
343 343
 							
344
-						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked , $OptionArray);
345
-					}else{
346
-						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked ,$OptionArray);
344
+						 $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $checked, $OptionArray);
345
+					} else {
346
+						 $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $checked, $OptionArray);
347 347
 					}
348 348
                 } else if ($fieldvalue[1] == 'TEXTAREA') {
349 349
 
350 350
                     if (isset($this->CI->input->post))
351
-                        $fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
351
+                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
352 352
                     else
353 353
                         $fieldvalue[2]['value'] = ($values) ? $values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
354
-                    $form_contents.= form_textarea($fieldvalue[2]);
354
+                    $form_contents .= form_textarea($fieldvalue[2]);
355 355
                 }
356 356
                 else if ($fieldvalue[2] == 'RADIO') {
357 357
 
358
-                    $form_contents.= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
358
+                    $form_contents .= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
359 359
                 }
360
-                $form_contents.= '</li>';
360
+                $form_contents .= '</li>';
361 361
             }
362 362
 
363
-            $form_contents.= '</ul>';
364
-            $form_contents.= '</div>';
365
-            $form_contents.= '</div>';
363
+            $form_contents .= '</ul>';
364
+            $form_contents .= '</div>';
365
+            $form_contents .= '</div>';
366 366
             $i++;
367 367
         }
368 368
 
369
-        $form_contents.= '<center><div class="col-md-12 margin-t-20 margin-b-20">';
369
+        $form_contents .= '<center><div class="col-md-12 margin-t-20 margin-b-20">';
370 370
 
371
-        $form_contents.= form_button($save);
371
+        $form_contents .= form_button($save);
372 372
 
373 373
 	if (isset($cancel)) {
374
-            $form_contents.= form_button($cancel);
374
+            $form_contents .= form_button($cancel);
375 375
         }
376
-        $form_contents.= '</center></div>';
377
-        $form_contents.= form_fieldset_close();
378
-        $form_contents.= form_close();
379
-        $form_contents.= '</div>';
376
+        $form_contents .= '</center></div>';
377
+        $form_contents .= form_fieldset_close();
378
+        $form_contents .= form_close();
379
+        $form_contents .= '</div>';
380 380
 
381 381
 
382 382
         return $form_contents;
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 
385 385
     function build_serach_form($fields_array) {
386 386
         $form_contents = '';
387
-        $form_contents.= '<div>';
388
-        $form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
387
+        $form_contents .= '<div>';
388
+        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
389 389
         unset($fields_array['forms']);
390 390
         $button_array = array();
391 391
 	/*******
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
                 $cancel = $fields_array['button_reset'];
399 399
                 unset($fields_array['button_reset']);
400 400
             }
401
-	    $button_search_delete='';
401
+	    $button_search_delete = '';
402 402
             if (isset($fields_array['button_search_delete'])) {
403 403
                 $button_search_delete = $fields_array['button_search_delete'];
404 404
                 unset($fields_array['button_search_delete']);
405 405
             }
406
-            if(isset($fields_array['display_in'])){
407
-	      $display_in=$fields_array['display_in'];
406
+            if (isset($fields_array['display_in'])) {
407
+	      $display_in = $fields_array['display_in'];
408 408
 	      unset($fields_array['display_in']);
409 409
 	    }
410 410
         }
@@ -412,31 +412,31 @@  discard block
 block discarded – undo
412 412
         $i = 1;
413 413
         foreach ($fields_array as $fieldset_key => $form_fileds) {
414 414
 
415
-            $form_contents.= '<ul class="padding-15">';
416
-            $form_contents.= form_fieldset(gettext($fieldset_key),array('style' => 'font-weight:bold;'),"search");
415
+            $form_contents .= '<ul class="padding-15">';
416
+            $form_contents .= form_fieldset(gettext($fieldset_key), array('style' => 'font-weight:bold;'), "search");
417 417
 
418 418
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
419 419
                 if ($i == 0) {
420
-                    $form_contents.= '<li class="col-md-12">';
420
+                    $form_contents .= '<li class="col-md-12">';
421 421
                 }
422
-                $form_contents.= '<div class="col-md-3 no-padding">';
422
+                $form_contents .= '<div class="col-md-3 no-padding">';
423 423
                 if ($fieldvalue[1] == 'HIDDEN') {
424
-                    $form_contents.= form_hidden($fieldvalue[2], $fieldvalue[3]);
424
+                    $form_contents .= form_hidden($fieldvalue[2], $fieldvalue[3]);
425 425
                 } else {
426
-                    $form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
426
+                    $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
427 427
                 }
428 428
                 if ($fieldvalue[1] == 'INPUT') {
429
-                    $form_contents.= form_input($fieldvalue[2]);
429
+                    $form_contents .= form_input($fieldvalue[2]);
430 430
                 }
431 431
 
432 432
 
433 433
                 if ($fieldvalue[2] == 'SELECT' || $fieldvalue[5] == '1') {
434 434
 			  
435 435
                     if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
436
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
436
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
437 437
 
438 438
                         $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
439
-                        $form_contents.=form_dropdown_all(gettext($fieldvalue[1]), $drp_array, '');
439
+                        $form_contents .= form_dropdown_all(gettext($fieldvalue[1]), $drp_array, '');
440 440
                     } else {
441 441
 
442 442
                         if ($fieldvalue[1] == 'INPUT') {
@@ -444,54 +444,54 @@  discard block
 block discarded – undo
444 444
                         }
445 445
 			
446 446
                         $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
447
-                        $form_contents.=form_dropdown_all_search(gettext($fieldvalue[1]), $drp_array, '');
447
+                        $form_contents .= form_dropdown_all_search(gettext($fieldvalue[1]), $drp_array, '');
448 448
                     }
449 449
                 } else if ($fieldvalue[1] == 'PASSWORD') {
450
-                    $form_contents.= form_password($fieldvalue[2]);
450
+                    $form_contents .= form_password($fieldvalue[2]);
451 451
                 } else if ($fieldvalue[2] == 'CHECKBOX') {
452
-                    $form_contents.= form_checkbox(gettext($fieldvalue[1]), $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
452
+                    $form_contents .= form_checkbox(gettext($fieldvalue[1]), $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
453 453
                 }
454
-                $form_contents.= '</div>';
454
+                $form_contents .= '</div>';
455 455
                 if ($i % 5 == 0) {
456
-                    $form_contents.= '</li>';
456
+                    $form_contents .= '</li>';
457 457
                     $i = 0;
458 458
                 }
459 459
                 $i++;
460 460
             }
461 461
         }
462
-        $form_contents.= '<div class="col-md-12 margin-t-20 margin-b-20">';
463
-        $form_contents.= form_button($cancel);
464
-        $form_contents.= form_button($save);
465
-        if(!empty($display_in)){
466
-            $form_contents.="<div class='col-md-5 pull-right'>";
467
-            $form_contents.="<div class='col-md-3'></div>";
468
-            $extra_parameters['class']=$display_in['label_class'];
469
-            $extra_parameters['style']=$display_in['label_style'];
470
-            $form_contents.=form_label($display_in['content'], "",$extra_parameters);
471
-            $drp_array = call_user_func_array(array($this->CI->common,$display_in['function']),array());
472
-            $extra_parameters['class']=$display_in['dropdown_class'];
473
-            $extra_parameters['style']=$display_in['dropdown_style'];
474
-            $form_contents.=form_dropdown_all_search($display_in, $drp_array, '',$extra_parameters);
475
-            $form_contents.="</div>";
462
+        $form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">';
463
+        $form_contents .= form_button($cancel);
464
+        $form_contents .= form_button($save);
465
+        if ( ! empty($display_in)) {
466
+            $form_contents .= "<div class='col-md-5 pull-right'>";
467
+            $form_contents .= "<div class='col-md-3'></div>";
468
+            $extra_parameters['class'] = $display_in['label_class'];
469
+            $extra_parameters['style'] = $display_in['label_style'];
470
+            $form_contents .= form_label($display_in['content'], "", $extra_parameters);
471
+            $drp_array = call_user_func_array(array($this->CI->common, $display_in['function']), array());
472
+            $extra_parameters['class'] = $display_in['dropdown_class'];
473
+            $extra_parameters['style'] = $display_in['dropdown_style'];
474
+            $form_contents .= form_dropdown_all_search($display_in, $drp_array, '', $extra_parameters);
475
+            $form_contents .= "</div>";
476 476
         }
477
-        if(isset($button_search_delete) && $button_search_delete != ''){
478
-	  $form_contents.= form_button($button_search_delete);
477
+        if (isset($button_search_delete) && $button_search_delete != '') {
478
+	  $form_contents .= form_button($button_search_delete);
479 479
         }
480
-        $form_contents.='<div class="col-md-12 no-padding margin-t-15" style="">
480
+        $form_contents .= '<div class="col-md-12 no-padding margin-t-15" style="">
481 481
 		<div class="pull-right btn-close" id="global_clearsearch_filter">Close</div> 
482 482
 	</div>';
483
-        $form_contents.= '</ul>';        
484
-        $form_contents.= '</div>';
485
-        $form_contents.= form_fieldset_close();
486
-        $form_contents.= form_close();
487
-        $form_contents.= '</div>';
483
+        $form_contents .= '</ul>';        
484
+        $form_contents .= '</div>';
485
+        $form_contents .= form_fieldset_close();
486
+        $form_contents .= form_close();
487
+        $form_contents .= '</div>';
488 488
 
489 489
         return $form_contents;
490 490
     }
491 491
     function build_batchupdate_form($fields_array) {
492 492
         $form_contents = '';
493
-        $form_contents.= '<div >';
494
-        $form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
493
+        $form_contents .= '<div >';
494
+        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
495 495
         unset($fields_array['forms']);
496 496
         $button_array = array();
497 497
         if (isset($fields_array['button_search']) || isset($fields_array['button_reset'])) {
@@ -505,69 +505,69 @@  discard block
 block discarded – undo
505 505
         $i = 1;
506 506
         foreach ($fields_array as $fieldset_key => $form_fileds) {
507 507
 
508
-            $form_contents.= '<ul>';
509
-            $form_contents.= form_fieldset(gettext($fieldset_key), array('style' => 'margin-left:-22px;font-weight:bold;'));
508
+            $form_contents .= '<ul>';
509
+            $form_contents .= form_fieldset(gettext($fieldset_key), array('style' => 'margin-left:-22px;font-weight:bold;'));
510 510
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
511 511
                 if ($i == 0) {
512
-                    $form_contents.= '<li>';
512
+                    $form_contents .= '<li>';
513 513
                 }
514
-                $form_contents.= '<div class="col-md-4 no-padding">';
514
+                $form_contents .= '<div class="col-md-4 no-padding">';
515 515
                 if ($fieldvalue[1] == 'HIDDEN') {
516
-                    $form_contents.= form_hidden($fieldvalue[2], $fieldvalue[3]);
516
+                    $form_contents .= form_hidden($fieldvalue[2], $fieldvalue[3]);
517 517
                 } else {
518
-                    $form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
518
+                    $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
519 519
                 }
520 520
                 if ($fieldvalue[2] == 'SELECT' || $fieldvalue[5] == '1') {
521 521
                     if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
522
-                        $str = $fieldvalue[7] . "," . $fieldvalue[8];
523
-                        if(is_array($fieldvalue[13])){
522
+                        $str = $fieldvalue[7].",".$fieldvalue[8];
523
+                        if (is_array($fieldvalue[13])) {
524 524
                             $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[14]), array($fieldvalue[13]));
525
-                            $form_contents.=form_dropdown($fieldvalue[13], $drp_array, '');
525
+                            $form_contents .= form_dropdown($fieldvalue[13], $drp_array, '');
526 526
                         }
527 527
                         /**
528 528
   		        ASTPP  3.0 
529 529
    		        Reseller Batch Update
530 530
                         **/ 
531
-                        if($fieldvalue[10] == 'set_status'){
532
-			$drp_array =array('0'=>'Active','1'=>'Inactive');
531
+                        if ($fieldvalue[10] == 'set_status') {
532
+			$drp_array = array('0'=>'Active', '1'=>'Inactive');
533 533
 			}
534 534
 			/************************************************************/
535
-			else{
536
-                        $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));}
537
-                        $form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, '');
535
+			else {
536
+                        $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12])); }
537
+                        $form_contents .= form_dropdown_all($fieldvalue[1], $drp_array, '');
538 538
                     } else {
539 539
                         if ($fieldvalue[1] == 'INPUT') {
540 540
                             $drp_name = $fieldvalue[6];
541 541
                         }
542 542
                         $drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
543
-                        $form_contents.=form_dropdown($drp_name, $drp_array, '');
543
+                        $form_contents .= form_dropdown($drp_name, $drp_array, '');
544 544
                     }
545 545
                 }
546 546
                 if ($fieldvalue[1] == 'INPUT') {
547
-                    $form_contents.= form_input($fieldvalue[2]);
547
+                    $form_contents .= form_input($fieldvalue[2]);
548 548
                 } else if ($fieldvalue[2] == 'CHECKBOX') {
549
-                    $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
549
+                    $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
550 550
                 }
551
-                $form_contents.= '</div>';
551
+                $form_contents .= '</div>';
552 552
                 if ($i % 5 == 0) {
553
-                    $form_contents.= '</li>';
553
+                    $form_contents .= '</li>';
554 554
                     $i = 0;
555 555
                 }
556 556
                 $i++;
557 557
             }
558 558
         }
559 559
 
560
-        $form_contents.= '</ul>';
561
-        $form_contents.= '<div class="col-md-12 margin-t-20 margin-b-20">';
560
+        $form_contents .= '</ul>';
561
+        $form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">';
562 562
 
563
-        $form_contents.= form_button($cancel);
564
-        $form_contents.= form_button($save);
565
-        $form_contents.='<div class="col-md-12 no-padding margin-t-15" style="margin-bottom:10px; !important">
563
+        $form_contents .= form_button($cancel);
564
+        $form_contents .= form_button($save);
565
+        $form_contents .= '<div class="col-md-12 no-padding margin-t-15" style="margin-bottom:10px; !important">
566 566
 						<div class="pull-right btn-close" id="global_clearbatchupdate_filter">Close</div></div>';
567
-        $form_contents.= form_fieldset_close();
568
-        $form_contents.= form_close();
569
-        $form_contents.= '</div>';
570
-        $form_contents.= '</div>';
567
+        $form_contents .= form_fieldset_close();
568
+        $form_contents .= form_close();
569
+        $form_contents .= '</div>';
570
+        $form_contents .= '</div>';
571 571
 
572 572
         return $form_contents;
573 573
     }
@@ -599,21 +599,21 @@  discard block
 block discarded – undo
599 599
                 ASTPP  3.0 
600 600
                 For Edit on Account number or name
601 601
             */
602
-		$row_id = isset($row['id']) ? $row["id"]: '';
602
+		$row_id = isset($row['id']) ? $row["id"] : '';
603 603
 /*****************************/
604 604
                 foreach ($grid_fields as $field_key => $field_arr) {
605 605
 /**
606 606
 ASTPP  3.0 
607 607
 For Edit on Account number or name
608 608
 **/
609
-		     $Actionkey = array_search(gettext('Action'), $this->CI->common->array_column($grid_fields,0));
609
+		     $Actionkey = array_search(gettext('Action'), $this->CI->common->array_column($grid_fields, 0));
610 610
 /*********************************/
611 611
                     if ($field_arr[2] != "") {
612 612
                         if ($field_arr[3] != "") {
613
-                           if($field_arr[2]=="status"){
613
+                           if ($field_arr[2] == "status") {
614 614
                             $row['id'] = $row_id;
615 615
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
616
-			   }else{
616
+			   } else {
617 617
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row[$field_arr[2]]));
618 618
 			   }
619 619
 
@@ -622,53 +622,53 @@  discard block
 block discarded – undo
622 622
 For Edit on Account number or name
623 623
 **/
624 624
 			    $row[$field_arr[2]] = $jsn_tmp[$field_key];
625
-            } if(array_search("EDITABLE", $field_arr)){
625
+            } if (array_search("EDITABLE", $field_arr)) {
626 626
 			    $ActionArr = $grid_fields[$Actionkey];
627
-                if($ActionArr[5]->EDIT->url =="accounts/customer_edit/" || $ActionArr[5]->EDIT->url =="accounts/provider_edit/"){
628
-                   $ActionArr[5]->EDIT->url=$row['type']==0 ?  "accounts/customer_edit/"  : "accounts/provider_edit/";
627
+                if ($ActionArr[5]->EDIT->url == "accounts/customer_edit/" || $ActionArr[5]->EDIT->url == "accounts/provider_edit/") {
628
+                   $ActionArr[5]->EDIT->url = $row['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/";
629 629
                 }
630
-                if($ActionArr[5]->EDIT->url =="accounts/admin_edit/" || $ActionArr[5]->EDIT->url =="accounts/subadmin_edit/"){
631
-                   $ActionArr[5]->EDIT->url=$row['type']==4 ?  "accounts/subadmin_edit/"  : "accounts/admin_edit/";
630
+                if ($ActionArr[5]->EDIT->url == "accounts/admin_edit/" || $ActionArr[5]->EDIT->url == "accounts/subadmin_edit/") {
631
+                   $ActionArr[5]->EDIT->url = $row['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/";
632 632
                 }
633 633
                 $acctype = "";
634
-                if(isset($row["type"]) && ($row["type"] == '0' || $row["type"] == '1' || $row["type"] == '3')){
635
-                    $acctype = (isset($row["posttoexternal"]) && $row["posttoexternal"] != '')? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("","",$row["posttoexternal"])."</span>":"";
634
+                if (isset($row["type"]) && ($row["type"] == '0' || $row["type"] == '1' || $row["type"] == '3')) {
635
+                    $acctype = (isset($row["posttoexternal"]) && $row["posttoexternal"] != '') ? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("", "", $row["posttoexternal"])."</span>" : "";
636 636
                 }
637 637
 
638
-                $fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
639
-                if($acctype != ''){
638
+                $fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT, $row[$field_arr[2]], $row["id"]);
639
+                if ($acctype != '') {
640 640
                     $jsn_tmp[$field_key] = $fieldstr."<br/>".$acctype;
641
-                }else{
641
+                } else {
642 642
                     $jsn_tmp[$field_key] = $fieldstr;
643 643
                 }
644 644
 			    
645 645
 
646 646
 /*********************************/
647
-		      }else {
647
+		      } else {
648 648
                             $jsn_tmp[$field_key] = $row[$field_arr[2]];
649 649
                   }                  				
650 650
             } else {
651 651
                 if ($field_arr[0] == gettext("Action")) {
652
-			    if(isset($field_arr[5]) && isset($field_arr[5]->EDIT) && isset($field_arr[5]->DELETE)){
652
+			    if (isset($field_arr[5]) && isset($field_arr[5]->EDIT) && isset($field_arr[5]->DELETE)) {
653 653
 		             
654
-		              if($field_arr[5]->EDIT->url == 'accounts/customer_edit/' || $field_arr[5]->EDIT->url == 'accounts/provider_edit/' || $field_arr[5]->DELETE->url == 'accounts/provider_delete/' ||$field_arr[5]->DELETE->url == 'accounts/customer_delete/'){
655
-		               if( $row['type'] == '0'|| strtolower($row['type']) == 'customer'){
656
-		                $field_arr[5]->EDIT->url ='accounts/customer_edit/';
657
-		                $field_arr[5]->DELETE->url ='accounts/customer_delete/';
654
+		              if ($field_arr[5]->EDIT->url == 'accounts/customer_edit/' || $field_arr[5]->EDIT->url == 'accounts/provider_edit/' || $field_arr[5]->DELETE->url == 'accounts/provider_delete/' || $field_arr[5]->DELETE->url == 'accounts/customer_delete/') {
655
+		               if ($row['type'] == '0' || strtolower($row['type']) == 'customer') {
656
+		                $field_arr[5]->EDIT->url = 'accounts/customer_edit/';
657
+		                $field_arr[5]->DELETE->url = 'accounts/customer_delete/';
658 658
 		               }
659
-		               if($row['type'] == 3 || strtolower($row['type']) == 'provider'){
660
-		                $field_arr[5]->EDIT->url ='accounts/provider_edit/';
661
-		                $field_arr[5]->DELETE->url ='accounts/provider_delete/';
659
+		               if ($row['type'] == 3 || strtolower($row['type']) == 'provider') {
660
+		                $field_arr[5]->EDIT->url = 'accounts/provider_edit/';
661
+		                $field_arr[5]->DELETE->url = 'accounts/provider_delete/';
662 662
 		               }
663 663
 		              }
664
-		              if($field_arr[5]->EDIT->url == 'accounts/admin_edit/' || $field_arr[5]->EDIT->url == 'accounts/subadmin_edit/' || $field_arr[5]->DELETE->url == 'accounts/admin_delete/' ||$field_arr[5]->DELETE->url == 'accounts/subadmin_delete/'){
665
-		               if($row['type'] == 2 || strtolower($row['type']) == 'administrator'){
666
-		                $field_arr[5]->EDIT->url ='accounts/admin_edit/';
667
-		                $field_arr[5]->DELETE->url ='accounts/admin_delete/';
664
+		              if ($field_arr[5]->EDIT->url == 'accounts/admin_edit/' || $field_arr[5]->EDIT->url == 'accounts/subadmin_edit/' || $field_arr[5]->DELETE->url == 'accounts/admin_delete/' || $field_arr[5]->DELETE->url == 'accounts/subadmin_delete/') {
665
+		               if ($row['type'] == 2 || strtolower($row['type']) == 'administrator') {
666
+		                $field_arr[5]->EDIT->url = 'accounts/admin_edit/';
667
+		                $field_arr[5]->DELETE->url = 'accounts/admin_delete/';
668 668
 		               }
669
-		               if($row['type'] == 4 || strtolower($row['type']) == 'sub admin'){
670
-		                $field_arr[5]->EDIT->url ='accounts/subadmin_edit/';
671
-		                $field_arr[5]->DELETE->url ='accounts/subadmin_delete/';
669
+		               if ($row['type'] == 4 || strtolower($row['type']) == 'sub admin') {
670
+		                $field_arr[5]->EDIT->url = 'accounts/subadmin_edit/';
671
+		                $field_arr[5]->DELETE->url = 'accounts/subadmin_delete/';
672 672
 		               }
673 673
 		            }
674 674
 			   }
@@ -679,16 +679,16 @@  discard block
 block discarded – undo
679 679
                             $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row_id);
680 680
                             /****************************************************************************/
681 681
                         }
682
-                        elseif($field_arr[0] == gettext("Profile Action"))
682
+                        elseif ($field_arr[0] == gettext("Profile Action"))
683 683
                         {
684
-                           if(isset($field_arr[5]) && isset($field_arr[5]->START) && isset($field_arr[5]->STOP) && isset($field_arr[5]->RELOAD) && isset($field_arr[5]->RESCAN)){
684
+                           if (isset($field_arr[5]) && isset($field_arr[5]->START) && isset($field_arr[5]->STOP) && isset($field_arr[5]->RELOAD) && isset($field_arr[5]->RESCAN)) {
685 685
                             }
686 686
                            $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
687 687
                         
688 688
                         }
689 689
                         else {
690
-                            $className = (isset($field_arr['9']) && $field_arr['9'] != '')?$field_arr['9']:"chkRefNos";
691
-                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id=' . $row['id'] . ' class="ace '.$className.'" onclick="clickchkbox(' . $row['id'] . ')" value=' . $row['id'] . '><lable class="lbl"></lable>';                        }
690
+                            $className = (isset($field_arr['9']) && $field_arr['9'] != '') ? $field_arr['9'] : "chkRefNos";
691
+                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id='.$row['id'].' class="ace '.$className.'" onclick="clickchkbox('.$row['id'].')" value='.$row['id'].'><lable class="lbl"></lable>'; }
692 692
                     }
693 693
                 }
694 694
                 $json_data[] = array('cell' => $jsn_tmp);
@@ -702,20 +702,20 @@  discard block
 block discarded – undo
702 702
         $json_data = array();
703 703
         foreach ($query as $row) {
704 704
             foreach ($grid_fields as $field_key => $field_arr) {
705
-                $row_id = isset($row['id']) ? $row["id"]: '';
705
+                $row_id = isset($row['id']) ? $row["id"] : '';
706 706
 /**
707 707
 ASTPP  3.0 
708 708
 For Edit on Account number or name
709 709
 **/
710
-		$Actionkey = array_search('Action',$this->CI->common->array_column($grid_fields,0)); 
710
+		$Actionkey = array_search('Action', $this->CI->common->array_column($grid_fields, 0)); 
711 711
 /*******************************/
712 712
 
713 713
                 if ($field_arr[2] != "") {
714 714
                     if ($field_arr[3] != "") {
715
-                         if($field_arr[2]=="status"){
715
+                         if ($field_arr[2] == "status") {
716 716
                             $row['id'] = $row_id;
717 717
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
718
-						 }else{
718
+						 } else {
719 719
                             $jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row[$field_arr[2]]));
720 720
 						 }
721 721
 /**
@@ -723,17 +723,17 @@  discard block
 block discarded – undo
723 723
 For Edit on Account number or name
724 724
 **/
725 725
  			$row[$field_arr[2]] = $jsn_tmp[$field_key];
726
-                      } if(array_search("EDITABLE", $field_arr)){
726
+                      } if (array_search("EDITABLE", $field_arr)) {
727 727
 			    $ActionArr = $grid_fields[$Actionkey];
728
-                if($ActionArr[5]->EDIT->url =="accounts/customer_edit/" || $ActionArr[5]->EDIT->url =="accounts/provider_edit/"){
729
-                   $ActionArr[5]->EDIT->url=$row['type']==0 ?  "accounts/customer_edit/"  : "accounts/provider_edit/";
728
+                if ($ActionArr[5]->EDIT->url == "accounts/customer_edit/" || $ActionArr[5]->EDIT->url == "accounts/provider_edit/") {
729
+                   $ActionArr[5]->EDIT->url = $row['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/";
730 730
                 }
731
-                if($ActionArr[5]->EDIT->url =="accounts/admin_edit/" || $ActionArr[5]->EDIT->url =="accounts/subadmin_edit/"){
732
-                   $ActionArr[5]->EDIT->url=$row['type']==4 ?  "accounts/subadmin_edit/"  : "accounts/admin_edit/";
731
+                if ($ActionArr[5]->EDIT->url == "accounts/admin_edit/" || $ActionArr[5]->EDIT->url == "accounts/subadmin_edit/") {
732
+                   $ActionArr[5]->EDIT->url = $row['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/";
733 733
                 }
734
-			    $jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
734
+			    $jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT, $row[$field_arr[2]], $row["id"]);
735 735
 /*******************************/
736
-		    }else {
736
+		    } else {
737 737
                         $jsn_tmp[$field_key] = isset($row[$field_arr[2]]) ? $row[$field_arr[2]] : "";
738 738
                     }
739 739
                 } else {
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
                         $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
742 742
                     }
743 743
 		      else {
744
-                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id=' . $row['id'] . ' class="ace chkRefNos" onclick="clickchkbox(' . $row['id'] . ')" value=' . $row['id'] . '><lable class="lbl"></lable>';
744
+                            $jsn_tmp[$field_key] = '<input type="checkbox" name="chkAll" id='.$row['id'].' class="ace chkRefNos" onclick="clickchkbox('.$row['id'].')" value='.$row['id'].'><lable class="lbl"></lable>';
745 745
                         }
746 746
                 }
747 747
             }
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/permission.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 # You should have received a copy of the GNU Affero General Public License
21 21
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
 ###############################################################################
23
-if (!defined('BASEPATH'))
23
+if ( ! defined('BASEPATH'))
24 24
     exit('No direct script access allowed');
25 25
 
26 26
 class Permission {
@@ -30,31 +30,31 @@  discard block
 block discarded – undo
30 30
 	$this->CI->load->library('session');
31 31
     }
32 32
 
33
-      function get_module_access($user_type){
33
+      function get_module_access($user_type) {
34 34
       $where = array("userlevelid"=>$user_type);
35
-       $modules_arr = $this->CI->db_model->getSelect("module_permissions","userlevels",$where);
36
-      if($modules_arr->num_rows > 0){
35
+       $modules_arr = $this->CI->db_model->getSelect("module_permissions", "userlevels", $where);
36
+      if ($modules_arr->num_rows > 0) {
37 37
 	$modules_arr = $modules_arr->result_array();
38 38
 	$modules_arr = $modules_arr[0]['module_permissions'];
39 39
 
40
-        $menu_arr = $this->CI->db_model->select("*","menu_modules","id IN ($modules_arr)","priority","asc","","","");
40
+        $menu_arr = $this->CI->db_model->select("*", "menu_modules", "id IN ($modules_arr)", "priority", "asc", "", "", "");
41 41
 	$menu_list = array(); 
42 42
 	$permited_modules = array();
43 43
         $modules_seq_arr = array();
44
-        $modules_seq_arr = explode(",",$modules_arr);
45
-        $label_arr=array();
46
-            foreach($menu_arr->result_array() as $menu_key =>$menu_value){ 
47
-                   if(!isset($label_arr[$menu_value['menu_label']]) && 	$menu_value['menu_label'] != 'Configuration'){
48
-		    $label_arr[$menu_value['menu_label']]=$menu_value['menu_label'];
49
-                    $menu_value["menu_image"] = ($menu_value["menu_image"] == "")?"Home.png":$menu_value["menu_image"];
44
+        $modules_seq_arr = explode(",", $modules_arr);
45
+        $label_arr = array();
46
+            foreach ($menu_arr->result_array() as $menu_key =>$menu_value) { 
47
+                   if ( ! isset($label_arr[$menu_value['menu_label']]) && $menu_value['menu_label'] != 'Configuration') {
48
+		    $label_arr[$menu_value['menu_label']] = $menu_value['menu_label'];
49
+                    $menu_value["menu_image"] = ($menu_value["menu_image"] == "") ? "Home.png" : $menu_value["menu_image"];
50 50
                     $menu_list[$menu_value["menu_title"]][$menu_value["menu_subtitle"]][] = array("menu_label" =>trim($menu_value["menu_label"]),
51
-                                                "module_url"=>trim($menu_value["module_url"]),"module"=>trim($menu_value["module_name"]),
51
+                                                "module_url"=>trim($menu_value["module_url"]), "module"=>trim($menu_value["module_name"]),
52 52
                                                 "menu_image"=>trim($menu_value["menu_image"]));                    
53 53
 		   }
54 54
                 $permited_modules[] = trim($menu_value["module_name"]);
55 55
             }                
56
-     	$this->CI->session->set_userdata('permited_modules',serialize($permited_modules));
57
-	$this->CI->session->set_userdata('menuinfo',serialize($menu_list));
56
+     	$this->CI->session->set_userdata('permited_modules', serialize($permited_modules));
57
+	$this->CI->session->set_userdata('menuinfo', serialize($menu_list));
58 58
   	return true;
59 59
       }
60 60
     }
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/email_lib.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
 ###############################################################################
23 23
 
24
-if (!defined('BASEPATH'))
24
+if ( ! defined('BASEPATH'))
25 25
     exit('No direct script access allowed');
26 26
 
27 27
 /**
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 class email_lib {
31 31
 
32 32
     protected $CI; // codeigniter
33
-    public $email='';
34
-    public $smtp='';
35
-    public $smtp_host='';
36
-    public $smtp_user='';
37
-    public $smtp_pass='';
38
-    public $smtp_port='';
39
-    public $message='';
40
-    public $from='';
41
-    public $to='';
42
-    public $subject='';
43
-    public $company_name='';
44
-    public $company_website='';
45
-    public $account_id='';
33
+    public $email = '';
34
+    public $smtp = '';
35
+    public $smtp_host = '';
36
+    public $smtp_user = '';
37
+    public $smtp_pass = '';
38
+    public $smtp_port = '';
39
+    public $message = '';
40
+    public $from = '';
41
+    public $to = '';
42
+    public $subject = '';
43
+    public $company_name = '';
44
+    public $company_website = '';
45
+    public $account_id = '';
46 46
 
47 47
     function __construct($library_name = '') {
48 48
 
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 		$where = array('group_title' =>'email');
58 58
 	        $query = $this->CI->db_model->getSelect("*", "system", $where);
59 59
 	        $query = $query->result_array();
60
-		foreach($query as $key=>$val){
60
+		foreach ($query as $key=>$val) {
61 61
 			$tempvar = strtolower($val['name']);
62
-			$this->$tempvar=$val['value'];
62
+			$this->$tempvar = $val['value'];
63 63
 		}
64 64
     }
65 65
 
66
-    function get_template( $type)
66
+    function get_template($type)
67 67
     {
68 68
 	$where = array('name' => $type);
69 69
         $query = $this->CI->db_model->getSelect("*", "default_templates", $where);
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 	$where = array('id' => $accountid);
78 78
         $query = $this->CI->db_model->getSelect("*", "accounts", $where);
79 79
         $query = $query->result_array();
80
-	if(isset($query[0]['email']) && $query[0]['email']!=''){
81
-		$query[0]['currency_name']=$this->CI->common->get_field_name('currency', 'currency', $query[0]['currency_id']);
82
-		$query[0]['timezone_name']=$this->CI->common->get_field_name('gmtzone', 'timezone', $query[0]['timezone_id']);
83
-		$query[0]['country_name']=$this->CI->common->get_field_name('country', 'countrycode', $query[0]['country_id']);
84
-		$this->to=$query[0]['email'];
80
+	if (isset($query[0]['email']) && $query[0]['email'] != '') {
81
+		$query[0]['currency_name'] = $this->CI->common->get_field_name('currency', 'currency', $query[0]['currency_id']);
82
+		$query[0]['timezone_name'] = $this->CI->common->get_field_name('gmtzone', 'timezone', $query[0]['timezone_id']);
83
+		$query[0]['country_name'] = $this->CI->common->get_field_name('country', 'countrycode', $query[0]['country_id']);
84
+		$this->to = $query[0]['email'];
85 85
 		$this->account_id = $query[0]['id'];
86 86
 		unset($query[0]['id']);
87
-		$query[0]['username']=$query[0]['number'];
87
+		$query[0]['username'] = $query[0]['number'];
88 88
 		unset($query[0]['number']);
89 89
 		return $query[0];
90 90
 	}
91 91
         return false;
92 92
     }
93 93
 
94
-    function get_info($id,$detail_type)
94
+    function get_info($id, $detail_type)
95 95
     {
96 96
 	$where = array('id' => $id);
97 97
         $query = $this->CI->db_model->getSelect("*", $detail_type, $where);
98 98
         $query = $query->result_array();
99
-	if(isset($query[0]['accountid'])){
100
-		$query=$this->get_account_info($query [0]['accountid']);
99
+	if (isset($query[0]['accountid'])) {
100
+		$query = $this->get_account_info($query [0]['accountid']);
101 101
 		return $query[0];
102 102
 	}
103 103
 	return false;
@@ -108,47 +108,47 @@  discard block
 block discarded – undo
108 108
 	$where = array();
109 109
         $query = $this->CI->db_model->getSelect("*", "invoice_conf", $where);
110 110
         $query = $query->result();
111
-	if(isset($query[0]->emailaddress) && $query[0]->emailaddress!=''){
112
-		$this->company_website=$query[0]->website;
113
-		$this->from=$query[0]->emailaddress;
114
-		$this->company_name=$query[0]->company_name;
111
+	if (isset($query[0]->emailaddress) && $query[0]->emailaddress != '') {
112
+		$this->company_website = $query[0]->website;
113
+		$this->from = $query[0]->emailaddress;
114
+		$this->company_name = $query[0]->company_name;
115 115
 		return true;
116 116
 	}
117 117
 	return false;
118 118
     }
119 119
 
120
-    function build_template($template_type,$detail,$detail_type='') {
121
-	if(!is_array($template_type))
120
+    function build_template($template_type, $detail, $detail_type = '') {
121
+	if ( ! is_array($template_type))
122 122
 		$this->get_template($template_type);
123
-	else{
124
-		$this->message=$template_type['message'];
125
-		$this->subject=$template_type['subject'];
126
-		$template_type='';
123
+	else {
124
+		$this->message = $template_type['message'];
125
+		$this->subject = $template_type['subject'];
126
+		$template_type = '';
127 127
 	}
128
-	if(is_array($detail))
128
+	if (is_array($detail))
129 129
 	{
130
-		$templateinfo=$detail;
131
-		if(isset($detail['email'])){
132
-			$this->to=$detail['email'];
130
+		$templateinfo = $detail;
131
+		if (isset($detail['email'])) {
132
+			$this->to = $detail['email'];
133 133
 		}
134 134
 /*****
135 135
 ASTPP  3.0 
136 136
 Email test
137 137
 ****/
138
-		if(isset($templateinfo['number'])){	
139
-			$templateinfo['username']=$templateinfo['number'];
138
+		if (isset($templateinfo['number'])) {	
139
+			$templateinfo['username'] = $templateinfo['number'];
140 140
 		}
141 141
 
142 142
 /*************/
143
-		$this->account_id=$templateinfo['accountid'];
143
+		$this->account_id = $templateinfo['accountid'];
144 144
 		unset($templateinfo['number']);
145 145
 	}
146
-	else if(!is_array($detail) && $detail_type=='')
147
-		$templateinfo=$this->get_account_info($detail);
146
+	else if ( ! is_array($detail) && $detail_type == '')
147
+		$templateinfo = $this->get_account_info($detail);
148 148
 	else
149
-		$templateinfo=$this->get_info($detail,$detail_type);
149
+		$templateinfo = $this->get_info($detail, $detail_type);
150 150
 
151
-	if($this->get_admin_details() && is_array($templateinfo) && isset($templateinfo['first_name']) && $templateinfo['first_name']!=''){
151
+	if ($this->get_admin_details() && is_array($templateinfo) && isset($templateinfo['first_name']) && $templateinfo['first_name'] != '') {
152 152
 		$this->message = html_entity_decode($this->message);
153 153
 		$this->message = str_replace("#COMPANY_EMAIL#", $this->from, $this->message);
154 154
 		$this->message = str_replace("#COMPANY_NAME#", $this->company_name, $this->message);
@@ -193,33 +193,33 @@  discard block
 block discarded – undo
193 193
 			   'status'=>'1',
194 194
 			   'attachment'=>$attachment
195 195
 			  );
196
-		$this->CI->db->insert('mail_details',$send_mail_details);
196
+		$this->CI->db->insert('mail_details', $send_mail_details);
197 197
 		return $this->CI->db->insert_id();
198 198
     }
199 199
     function update_mail_history($id)
200 200
     {
201 201
 		$this->CI->db->where(array('id' => $id));
202 202
 		$send_mail_details = array('status'=>'0');
203
-		$this->CI->db->update('mail_details',$send_mail_details);
203
+		$this->CI->db->update('mail_details', $send_mail_details);
204 204
     }
205 205
     function set_email_paramenters($details)
206 206
     {
207
-		if(!is_array($details)){
207
+		if ( ! is_array($details)) {
208 208
 			$this->get_admin_details();
209 209
 			$where = array('id'=>$details);
210 210
 			$query = $this->CI->db_model->getSelect("*", "mail_details", $where);
211 211
 			$query = $query->result_array();
212
-			$details=$query[0];
212
+			$details = $query[0];
213 213
 		}
214
-		$this->message=$details['body'];
215
-		$this->from=$details['from'];
216
-		$this->to=$details['to'];
217
-		$this->subject=$details['subject'];
218
-		$this->account_id=$details['accountid'];
214
+		$this->message = $details['body'];
215
+		$this->from = $details['from'];
216
+		$this->to = $details['to'];
217
+		$this->subject = $details['subject'];
218
+		$this->account_id = $details['accountid'];
219 219
     }
220 220
     function get_smtp_details()
221 221
     {
222
-	if($this->smtp_port=='' || $this->smtp_host=='' || $this->smtp_user=='' || $this->smtp_pass=='')exit;
222
+	if ($this->smtp_port == '' || $this->smtp_host == '' || $this->smtp_user == '' || $this->smtp_pass == '')exit;
223 223
 		$config['protocol'] = "smtp";
224 224
 		$config['smtp_host'] = $this->smtp_host;
225 225
 		$config['smtp_port'] = $this->smtp_port;
@@ -231,21 +231,21 @@  discard block
 block discarded – undo
231 231
 		$this->CI->email->initialize($config);
232 232
     }
233 233
 
234
-    function send_email($template_type,$details,$detail_type='',$attachment='',$resend=0,$mass_mail=0,$brodcast=0) {
234
+    function send_email($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) {
235 235
 	$this->get_email_settings();
236
-	if(!$this->email){
237
-		if(!$resend){
238
-			$this->build_template($template_type,$details,$detail_type);
239
-		}else{
236
+	if ( ! $this->email) {
237
+		if ( ! $resend) {
238
+			$this->build_template($template_type, $details, $detail_type);
239
+		} else {
240 240
 			$this->set_email_paramenters($details);
241 241
 		}
242 242
 
243
-		if(!$brodcast)
244
-	        	$history_id=$this->mail_history($attachment);
243
+		if ( ! $brodcast)
244
+	        	$history_id = $this->mail_history($attachment);
245 245
 		else	
246
-			$history_id=$details['history_id'];
247
-		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
248
-			if(!$this->smtp){
246
+			$history_id = $details['history_id'];
247
+		if (isset($this->from) && $this->from != '' && isset($this->to) && $this->to != '' && ! $mass_mail) {
248
+			if ( ! $this->smtp) {
249 249
 				$this->get_smtp_details();
250 250
 			}			
251 251
 			$this->CI->email->from($this->from, $this->company_name);
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 			eval("\$message = \"".$this->message."\";");
256 256
 			$this->CI->email->message($this->message);
257 257
 
258
-			if($attachment!="")
258
+			if ($attachment != "")
259 259
 			{
260
-			        $attac_exp=explode(",",$attachment);
261
-		       	  	foreach($attac_exp as $key=>$value){
262
-			   		if($value != ''){
260
+			        $attac_exp = explode(",", $attachment);
261
+		       	  	foreach ($attac_exp as $key=>$value) {
262
+			   		if ($value != '') {
263 263
 			       	$this->CI->email->attach(getcwd()."/attachments/".$value);       	  	
264 264
 				   	}
265 265
 				}
@@ -274,22 +274,22 @@  discard block
 block discarded – undo
274 274
 ASTPP  3.0 
275 275
 Add For Signup Module
276 276
 **/
277
-    function send_mail($template_type,$details,$detail_type='',$attachment='',$resend=0,$mass_mail=0,$brodcast=0) {
277
+    function send_mail($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) {
278 278
 	$this->get_email_settings();
279
-	if(!$this->email){
279
+	if ( ! $this->email) {
280 280
 		
281
-		if(!$resend){
282
-			$this->build_template($template_type,$details,$detail_type);
283
-		}else{
281
+		if ( ! $resend) {
282
+			$this->build_template($template_type, $details, $detail_type);
283
+		} else {
284 284
 			$this->set_email_paramenters($details);
285 285
 		}
286 286
 
287
-		if(!$brodcast)
288
-	        	$history_id=$this->mail_history($attachment);
287
+		if ( ! $brodcast)
288
+	        	$history_id = $this->mail_history($attachment);
289 289
 		else	
290
-			$history_id=$details['history_id'];
291
-		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
292
-			if(!$this->smtp){
290
+			$history_id = $details['history_id'];
291
+		if (isset($this->from) && $this->from != '' && isset($this->to) && $this->to != '' && ! $mass_mail) {
292
+			if ( ! $this->smtp) {
293 293
 				$this->get_smtp_details();
294 294
 			}			
295 295
 			$this->CI->email->from($this->from, $this->company_name);
Please login to merge, or discard this patch.