Completed
Push — v3.0 ( 541912...7b8f24 )
by Samir
12:38 queued 01:00
created
web_interface/astpp/application/libraries/csvreader.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -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.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
+<?php if ( ! defined('BASEPATH')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
 * CSVReader Class
4 6
 *
@@ -94,8 +96,9 @@  discard block
 block discarded – undo
94 96
 			$field_key_value =$config_variable[$field_name_arr[$j]];
95 97
 		$value= strip_slashes(trim($value));
96 98
 				$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));                  
99
+				if(isset($field_key_value) && !empty($field_key_value)) {
100
+						  $content[$field_key_value] =  strip_tags(filter_var($value, FILTER_SANITIZE_STRING));
101
+				}
99 102
 		$j++;
100 103
 		}  
101 104
 	  }
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
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
 	exit('No direct script access allowed');
25 25
 }
26 26
 class Timezone {
27
-  function __construct(){
28
-	$this->CI =& get_instance();
27
+  function __construct() {
28
+	$this->CI = & get_instance();
29 29
 	$this->CI->load->library('session');
30 30
 	$this->CI->load->database();
31 31
   }
32 32
 
33
-  function uset_timezone(){
33
+  function uset_timezone() {
34 34
 		$account_data = $this->CI->session->userdata('accountinfo');
35
-		return $account_data['timezone_id'] ;
35
+		return $account_data['timezone_id'];
36 36
   }
37
-  function display_GMT($currDate,$fulldate = 1)
37
+  function display_GMT($currDate, $fulldate = 1)
38 38
   {	
39 39
 	  $number = $this->uset_timezone();
40
-	  $SERVER_GMT='0';
40
+	  $SERVER_GMT = '0';
41 41
 
42
-	  $result=$this->CI->db->query("select gmtoffset from timezone where id =".$number);
42
+	  $result = $this->CI->db->query("select gmtoffset from timezone where id =".$number);
43 43
 	  $timezone_offset = $result->result();
44 44
 
45 45
 	  $USER_GMT = $timezone_offset['0']->gmtoffset;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	  $year = $date_time_array['year'];
55 55
 	  $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
56 56
 
57
-	  $timestamp = $timestamp+($USER_GMT-$SERVER_GMT);
57
+	  $timestamp = $timestamp + ($USER_GMT - $SERVER_GMT);
58 58
 	  if ($fulldate == 1) {
59 59
 		$date = date("Y-m-d H:i:s", $timestamp);
60 60
 	  } else {
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	  return $date;
65 65
   }
66 66
 
67
-  function convert_to_GMT($currDate,$fulldate = 1){
67
+  function convert_to_GMT($currDate, $fulldate = 1) {
68 68
 	  $number = $this->uset_timezone();
69
-	  $SERVER_GMT='0';
69
+	  $SERVER_GMT = '0';
70 70
 
71
-	  $result=$this->CI->db->query("select gmtoffset from timezone where id =".$number);
71
+	  $result = $this->CI->db->query("select gmtoffset from timezone where id =".$number);
72 72
 	  $timezone_offset = $result->result();
73 73
 
74 74
 	  $USER_GMT = $timezone_offset['0']->gmtoffset;
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/form.php 3 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -22,180 +22,180 @@
 block discarded – undo
22 22
 ###############################################################################
23 23
 
24 24
 if ( ! defined('BASEPATH'))
25
-    exit('No direct script access allowed');
25
+	exit('No direct script access allowed');
26 26
 
27 27
 /**
28 28
  * Dynamically build forms for display
29 29
  */
30 30
 class Form {
31 31
 
32
-    protected $CI; // codeigniter
33
-    protected $fields = array(); // array of fields
34
-    protected $form_title = 'Form';
35
-    protected $form_id = 'form';
36
-    protected $form_action = '';
37
-    protected $form_class = '';
38
-    protected $hidden = array();
39
-    protected $multipart = FALSE; // default to standard form
40
-    protected $submit_button = 'Submit';
41
-    protected $after_button = '';
42
-    protected $rules = array(); // storage for validation rules
43
-
44
-    function __construct() {
45
-        $this->CI = & get_instance();
46
-        $this->CI->load->library('form_validation');
47
-        $this->CI->load->library('astpp/common');
48
-        $this->CI->load->model('db_model');
49
-        $this->check_permissions();
50
-    }
32
+	protected $CI; // codeigniter
33
+	protected $fields = array(); // array of fields
34
+	protected $form_title = 'Form';
35
+	protected $form_id = 'form';
36
+	protected $form_action = '';
37
+	protected $form_class = '';
38
+	protected $hidden = array();
39
+	protected $multipart = FALSE; // default to standard form
40
+	protected $submit_button = 'Submit';
41
+	protected $after_button = '';
42
+	protected $rules = array(); // storage for validation rules
43
+
44
+	function __construct() {
45
+		$this->CI = & get_instance();
46
+		$this->CI->load->library('form_validation');
47
+		$this->CI->load->library('astpp/common');
48
+		$this->CI->load->model('db_model');
49
+		$this->check_permissions();
50
+	}
51 51
 
52 52
 // __construct
53
-    /**
54
-     * adds raw html to the field array
55
-     */
56
-    function check_permissions() {
57
-        if ($this->CI->session->userdata('user_login') == TRUE) {
58
-            $module_info = unserialize($this->CI->session->userdata("permited_modules"));
59
-            if ($this->CI->session->userdata('userlevel_logintype') != 0 && $this->CI->session->userdata('userlevel_logintype') != 3) {
60
-	    $module_info[] = 'dashboard';
61
-            }
62
-            $url = $this->CI->uri->uri_string;
63
-            $file_name = explode("/", $url);
64
-            if (isset($file_name['1'])) {
65
-	      $module = explode('_', $file_name['1']);
66
-            } else {
67
-              $module = $file_name;
68
-            }
69
-            if ($this->CI->session->userdata('userlevel_logintype') == 1) {
53
+	/**
54
+	 * adds raw html to the field array
55
+	 */
56
+	function check_permissions() {
57
+		if ($this->CI->session->userdata('user_login') == TRUE) {
58
+			$module_info = unserialize($this->CI->session->userdata("permited_modules"));
59
+			if ($this->CI->session->userdata('userlevel_logintype') != 0 && $this->CI->session->userdata('userlevel_logintype') != 3) {
60
+		$module_info[] = 'dashboard';
61
+			}
62
+			$url = $this->CI->uri->uri_string;
63
+			$file_name = explode("/", $url);
64
+			if (isset($file_name['1'])) {
65
+		  $module = explode('_', $file_name['1']);
66
+			} else {
67
+			  $module = $file_name;
68
+			}
69
+			if ($this->CI->session->userdata('userlevel_logintype') == 1) {
70 70
 				$module_info[] = 'user';
71 71
 			}
72
-            if (in_array($module[0], $module_info)) {
73
-                if ($this->CI->session->userdata('userlevel_logintype') == 0 && $module[0] == 'customer' && isset($file_name[1]) && $file_name[1] != 'customer_transfer') {
74
-                     redirect(base_url().'user/user/');
75
-                } else {
76
-                   return true;
77
-                }
78
-            } else {
79
-                $this->CI->session->set_userdata('astpp_errormsg', 'You do not have permission to access this module..!');
80
-                if ($this->CI->session->userdata('userlevel_logintype') == '-1' || $this->CI->session->userdata('logintype') == '1') {
81
-                    redirect(base_url().'dashboard/');
82
-                } else {
83
-                    redirect(base_url().'user/user/');
84
-                }
85
-            }
86
-        } else {
87
-            redirect(base_url());
88
-        }
89
-    }
90
-
91
-    function build_form($fields_array, $values) {
92
-        $form_contents = '';
93
-        $form_contents .= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">';
94
-        if (isset($fields_array['breadcrumb'])) {
95
-            $form_contents .= form_breadcrumb($fields_array['breadcrumb']);
96
-            unset($fields_array['breadcrumb']);
97
-        }
98
-        $form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
99
-        unset($fields_array['forms']);
100
-        $button_array = array();
101
-        if (isset($fields_array['button_save']) || isset($fields_array['button_cancel']) || isset($fields_array['additional_button'])) {
102
-            $save = $fields_array['button_save'];
103
-            unset($fields_array['button_save']);
104
-            if (isset($fields_array['button_cancel'])) {
105
-                $cancel = $fields_array['button_cancel'];
106
-                unset($fields_array['button_cancel']);
107
-            }
108
-            if (isset($fields_array['additional_button'])) {
109
-                $additiopnal_button = $fields_array['additional_button'];
110
-                unset($fields_array['additional_button']);
111
-            }
112
-        }
113
-        if (isset($additiopnal_button)) {
114
-            $form_contents .= form_button(gettext($additiopnal_button));
115
-        }
116
-        $i = 0;
117
-        foreach ($fields_array as $fieldset_key => $form_fileds) {
118
-            if (count($fields_array) > 1) {
119
-                if ($i == 1 || $i == 3) {
120
-                    $form_contents .= '<div class="col-md-6 no-padding pull-right">';
121
-                    $form_contents .= '<div class="col-md-12 padding-x-4">';
122
-                } else {
123
-                    $form_contents .= '<div class="col-md-6 no-padding">';
124
-                    $form_contents .= '<div class="col-md-12 padding-x-4">';
125
-                }
126
-            } else {
127
-               $form_contents .= '<div class="col-md-12 no-padding">';
128
-                $form_contents .= '<div class="col-md-12 no-padding">';
129
-            }
130
-            $form_contents .= '<ul class="no-padding">';
131
-                $form_contents .= '<div class="col-md-12 no-padding">';
132
-            if ($i == 1 || $i == 3) {
133
-                $form_contents .= form_fieldset(gettext($fieldset_key));
134
-            } else {
135
-                $form_contents .= form_fieldset(gettext($fieldset_key));
136
-            }
137
-            foreach ($form_fileds as $fieldkey => $fieldvalue) {
138
-                $form_contents .= '<li class="col-md-12">';
139
-                if ($fieldvalue[1] == 'HIDDEN') {
140
-                    if (isset($this->CI->input->post))
141
-                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
142
-                    else
143
-                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
144
-                    $form_contents .= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
145
-                } else {
146
-		      $validation_arr = array();
147
-		      if ($fieldvalue[1] == 'INPUT') {
148
-		        if ( ! empty($fieldvalue[3])) {
149
-		          $validation_arr = explode("|", $fieldvalue[3]);
150
-		        }
151
-		      }
152
-		      elseif ($fieldvalue[2] == 'SELECT') {
153
-
154
-		        if (is_array($fieldvalue[4])) {
155
-		          $validation_arr = explode("|", $fieldvalue[4]['rules']);
156
-		        } else {
157
-		        $validation_arr = explode("|", $fieldvalue[4]);
158
-		        }
159
-		      }
160
-		      if ( ! empty($validation_arr)) {
161
-		      $fieldvalue[0] = in_array('required', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
162
-		      $fieldvalue[0] = in_array('dropdown', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
163
-		      }
72
+			if (in_array($module[0], $module_info)) {
73
+				if ($this->CI->session->userdata('userlevel_logintype') == 0 && $module[0] == 'customer' && isset($file_name[1]) && $file_name[1] != 'customer_transfer') {
74
+					 redirect(base_url().'user/user/');
75
+				} else {
76
+				   return true;
77
+				}
78
+			} else {
79
+				$this->CI->session->set_userdata('astpp_errormsg', 'You do not have permission to access this module..!');
80
+				if ($this->CI->session->userdata('userlevel_logintype') == '-1' || $this->CI->session->userdata('logintype') == '1') {
81
+					redirect(base_url().'dashboard/');
82
+				} else {
83
+					redirect(base_url().'user/user/');
84
+				}
85
+			}
86
+		} else {
87
+			redirect(base_url());
88
+		}
89
+	}
90
+
91
+	function build_form($fields_array, $values) {
92
+		$form_contents = '';
93
+		$form_contents .= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">';
94
+		if (isset($fields_array['breadcrumb'])) {
95
+			$form_contents .= form_breadcrumb($fields_array['breadcrumb']);
96
+			unset($fields_array['breadcrumb']);
97
+		}
98
+		$form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
99
+		unset($fields_array['forms']);
100
+		$button_array = array();
101
+		if (isset($fields_array['button_save']) || isset($fields_array['button_cancel']) || isset($fields_array['additional_button'])) {
102
+			$save = $fields_array['button_save'];
103
+			unset($fields_array['button_save']);
104
+			if (isset($fields_array['button_cancel'])) {
105
+				$cancel = $fields_array['button_cancel'];
106
+				unset($fields_array['button_cancel']);
107
+			}
108
+			if (isset($fields_array['additional_button'])) {
109
+				$additiopnal_button = $fields_array['additional_button'];
110
+				unset($fields_array['additional_button']);
111
+			}
112
+		}
113
+		if (isset($additiopnal_button)) {
114
+			$form_contents .= form_button(gettext($additiopnal_button));
115
+		}
116
+		$i = 0;
117
+		foreach ($fields_array as $fieldset_key => $form_fileds) {
118
+			if (count($fields_array) > 1) {
119
+				if ($i == 1 || $i == 3) {
120
+					$form_contents .= '<div class="col-md-6 no-padding pull-right">';
121
+					$form_contents .= '<div class="col-md-12 padding-x-4">';
122
+				} else {
123
+					$form_contents .= '<div class="col-md-6 no-padding">';
124
+					$form_contents .= '<div class="col-md-12 padding-x-4">';
125
+				}
126
+			} else {
127
+			   $form_contents .= '<div class="col-md-12 no-padding">';
128
+				$form_contents .= '<div class="col-md-12 no-padding">';
129
+			}
130
+			$form_contents .= '<ul class="no-padding">';
131
+				$form_contents .= '<div class="col-md-12 no-padding">';
132
+			if ($i == 1 || $i == 3) {
133
+				$form_contents .= form_fieldset(gettext($fieldset_key));
134
+			} else {
135
+				$form_contents .= form_fieldset(gettext($fieldset_key));
136
+			}
137
+			foreach ($form_fileds as $fieldkey => $fieldvalue) {
138
+				$form_contents .= '<li class="col-md-12">';
139
+				if ($fieldvalue[1] == 'HIDDEN') {
140
+					if (isset($this->CI->input->post))
141
+						$fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
142
+					else
143
+						$fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
144
+					$form_contents .= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
145
+				} else {
146
+			  $validation_arr = array();
147
+			  if ($fieldvalue[1] == 'INPUT') {
148
+				if ( ! empty($fieldvalue[3])) {
149
+				  $validation_arr = explode("|", $fieldvalue[3]);
150
+				}
151
+			  }
152
+			  elseif ($fieldvalue[2] == 'SELECT') {
153
+
154
+				if (is_array($fieldvalue[4])) {
155
+				  $validation_arr = explode("|", $fieldvalue[4]['rules']);
156
+				} else {
157
+				$validation_arr = explode("|", $fieldvalue[4]);
158
+				}
159
+			  }
160
+			  if ( ! empty($validation_arr)) {
161
+			  $fieldvalue[0] = in_array('required', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
162
+			  $fieldvalue[0] = in_array('dropdown', $validation_arr) ? $fieldvalue[0]."<span style='color:black;'> *</span>" : $fieldvalue[0];
163
+			  }
164 164
  
165
-                    if (is_array($fieldvalue[1]) || (is_array($fieldvalue[2]) && isset($fieldvalue[2]['hidden']))) {
166
-                        $form_contents .= form_label(gettext($fieldvalue[0]), $fieldvalue[0], array('class' => 'col-md-3 no-padding add_settings'));
167
-                    } else {
168
-                        $form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "col-md-3 no-padding"));
169
-                    }
170
-                }
171
-                if ($fieldvalue[2] == 'SELECT' && ! isset($fieldvalue[13])) {
172
-
173
-                /*
165
+					if (is_array($fieldvalue[1]) || (is_array($fieldvalue[2]) && isset($fieldvalue[2]['hidden']))) {
166
+						$form_contents .= form_label(gettext($fieldvalue[0]), $fieldvalue[0], array('class' => 'col-md-3 no-padding add_settings'));
167
+					} else {
168
+						$form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "col-md-3 no-padding"));
169
+					}
170
+				}
171
+				if ($fieldvalue[2] == 'SELECT' && ! isset($fieldvalue[13])) {
172
+
173
+				/*
174 174
                  To make Drop down enabled disabled
175 175
                 */
176
-                 $extra = isset($fieldvalue[1]['extra']) ? $fieldvalue[1]['extra'] : '';
177
-                 /***************************/
178
-                    if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
179
-                        $str = $fieldvalue[7].",".$fieldvalue[8];
180
-
181
-                        if (isset($this->CI->input->post)) {
182
-                            $fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
183
-                        } else {
184
-                            if (is_array($fieldvalue[1])) {
185
-                                $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
186
-                            } else {
187
-                                $fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
188
-                            }
189
-                        }
190
-                        $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
191
-
192
-                        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')) {
193
-                            $form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
194
-                        } else {
195
-                            $form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
196
-                        }
197
-			            if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
198
-                        	if(is_array($fieldvalue[4])){
176
+				 $extra = isset($fieldvalue[1]['extra']) ? $fieldvalue[1]['extra'] : '';
177
+				 /***************************/
178
+					if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
179
+						$str = $fieldvalue[7].",".$fieldvalue[8];
180
+
181
+						if (isset($this->CI->input->post)) {
182
+							$fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
183
+						} else {
184
+							if (is_array($fieldvalue[1])) {
185
+								$fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
186
+							} else {
187
+								$fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
188
+							}
189
+						}
190
+						$drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
191
+
192
+						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')) {
193
+							$form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
194
+						} else {
195
+							$form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
196
+						}
197
+						if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
198
+							if(is_array($fieldvalue[4])){
199 199
 								
200 200
 								if(isset($fieldvalue[1]['name'])){
201 201
 									$fieldvalue_pass=$fieldvalue[1]['name'];
Please login to merge, or discard this patch.
Spacing   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -189,38 +189,38 @@  discard block
 block discarded – undo
189 189
                         }
190 190
                         $drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
191 191
 
192
-                        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')) {
193
-                            $form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
192
+                        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')) {
193
+                            $form_contents .= form_dropdown_all($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
194 194
                         } else {
195
-                            $form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
195
+                            $form_contents .= form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
196 196
                         }
197
-			            if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
198
-                        	if(is_array($fieldvalue[4])){
197
+			            if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
198
+                        	if (is_array($fieldvalue[4])) {
199 199
 								
200
-								if(isset($fieldvalue[1]['name'])){
201
-									$fieldvalue_pass=$fieldvalue[1]['name'];
202
-								}else{
203
-									$fieldvalue_pass=$fieldvalue[1];
200
+								if (isset($fieldvalue[1]['name'])) {
201
+									$fieldvalue_pass = $fieldvalue[1]['name'];
202
+								} else {
203
+									$fieldvalue_pass = $fieldvalue[1];
204 204
 								}
205 205
 								
206 206
 								$this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]['rules']);
207
-							}else{
207
+							} else {
208 208
 								
209
-								if(isset($fieldvalue[1]['name'])){
210
-									$fieldvalue_pass=$fieldvalue[1]['name'];
211
-								}else{
212
-									$fieldvalue_pass=$fieldvalue[1];
209
+								if (isset($fieldvalue[1]['name'])) {
210
+									$fieldvalue_pass = $fieldvalue[1]['name'];
211
+								} else {
212
+									$fieldvalue_pass = $fieldvalue[1];
213 213
 								}
214 214
 								
215 215
 							   $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]);
216 216
 							}   
217 217
 						}
218
-						$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>';
219
-						$form_contents.= '<span class="popup_error error  no-padding" id="'.(gettext(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1])).'_error">
218
+						$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>';
219
+						$form_contents .= '<span class="popup_error error  no-padding" id="'.(gettext(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1])).'_error">
220 220
                         </span></div>';                         
221 221
 					} else {
222 222
 						if (isset($this->CI->input->post)) {
223
-							$fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
223
+							$fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
224 224
 						} else {
225 225
 							if (is_array($fieldvalue[1])) {
226 226
 								$fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]['name']] : @$fieldvalue[1];
@@ -229,53 +229,53 @@  discard block
 block discarded – undo
229 229
 							}
230 230
 						}
231 231
 
232
-						$str = $fieldvalue[7] . "," . $fieldvalue[8];
232
+						$str = $fieldvalue[7].",".$fieldvalue[8];
233 233
 						$drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
234
-						$form_contents.=form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'],$extra);
235
-						if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
234
+						$form_contents .= form_dropdown($fieldvalue[1], $drp_array, $fieldvalue['value'], $extra);
235
+						if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
236 236
 			  $this->CI->form_validation->set_rules($fieldvalue[1], $fieldvalue[0], $fieldvalue[4]);
237 237
 						}
238
-						$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>';
239
-						$form_contents.= '<span class="popup_error error  no-padding" id="'.(is_array($fieldvalue[1])?$fieldvalue[1]['name']:$fieldvalue[1]).'_error">
238
+						$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>';
239
+						$form_contents .= '<span class="popup_error error  no-padding" id="'.(is_array($fieldvalue[1]) ? $fieldvalue[1]['name'] : $fieldvalue[1]).'_error">
240 240
                         </span></div>';                        
241 241
 					}
242 242
 				} else if (isset($fieldvalue[13]) && $fieldvalue[13] != '') {
243 243
 
244 244
 					/* For multi select code */
245
-					$str = $fieldvalue[7] . "," . $fieldvalue[8];
245
+					$str = $fieldvalue[7].",".$fieldvalue[8];
246 246
 
247 247
 					if (isset($this->CI->input->post))
248
-						$fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
248
+						$fieldvalue['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
249 249
 					else
250 250
 						$fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
251 251
 
252 252
 					$drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
253 253
 					if ($fieldset_key === 'System Configuration Information') {
254
-						$form_contents.=form_dropdown_multiselect($fieldvalue[1], $drp_array, '');
254
+						$form_contents .= form_dropdown_multiselect($fieldvalue[1], $drp_array, '');
255 255
 					} else {
256
-						$form_contents.=form_dropdown_multiselect($fieldvalue[1] . "[]", $drp_array, $fieldvalue['value']);
256
+						$form_contents .= form_dropdown_multiselect($fieldvalue[1]."[]", $drp_array, $fieldvalue['value']);
257 257
 					}
258
-					if(isset($fieldvalue[4]) && $fieldvalue[4] != ''){
258
+					if (isset($fieldvalue[4]) && $fieldvalue[4] != '') {
259 259
 			$this->CI->form_validation->set_rules($fieldvalue[1], $fieldvalue[0], $fieldvalue[4]);
260 260
 					}
261
-					$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>';
262
-					$form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[1].'_error"></span></div>';                   
261
+					$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>';
262
+					$form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[1].'_error"></span></div>';                   
263 263
 					/* End---------------------   For multi select code */
264 264
 				} else if ($fieldvalue[1] == 'INPUT') {
265 265
 
266 266
 
267 267
 					if (isset($this->CI->input->post))
268
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
269
-					else{
270
-						$fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : ''):(isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] :'');
268
+						$fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
269
+					else {
270
+						$fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
271 271
 					}    
272
-					$form_contents.= form_input($fieldvalue[2], 'readonly');
273
-					if(isset($fieldvalue[6]) && !empty($fieldvalue[6])){
274
-						$form_contents.=$fieldvalue[6];
272
+					$form_contents .= form_input($fieldvalue[2], 'readonly');
273
+					if (isset($fieldvalue[6]) && ! empty($fieldvalue[6])) {
274
+						$form_contents .= $fieldvalue[6];
275 275
 					}    
276 276
 					$this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
277
-					$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>';
278
-					$form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
277
+					$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>';
278
+					$form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
279 279
                     </span></div>';
280 280
 				}
281 281
 				/* 
@@ -283,98 +283,98 @@  discard block
 block discarded – undo
283 283
                  */
284 284
 				else if ($fieldvalue[1] == 'IMAGE') {
285 285
 					if (isset($this->CI->input->post))
286
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
286
+						$fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
287 287
                        
288 288
 					else
289 289
 						$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
290 290
 						$fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
291
-					$form_contents.= form_image($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
292
-						 $form_contents.=@$fieldvalue[6];
291
+					$form_contents .= form_image($fieldvalue[2], 'readonly', $fieldvalue[2]['style']);
292
+						 $form_contents .= @$fieldvalue[6];
293 293
 					$this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
294
-					$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>';
295
-					$form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
294
+					$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>';
295
+					$form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
296 296
                     </span></div>';
297 297
 				}
298 298
 				else if ($fieldvalue[1] == 'DEL_BUTTON') {
299 299
 					if (isset($this->CI->input->post))
300
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
300
+						$fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
301 301
                        
302 302
 					else
303 303
 						$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
304 304
 						$fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
305
-					$form_contents.= form_img_delete($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
306
-						 $form_contents.=@$fieldvalue[6];
305
+					$form_contents .= form_img_delete($fieldvalue[2], 'readonly', $fieldvalue[2]['style']);
306
+						 $form_contents .= @$fieldvalue[6];
307 307
 					$this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
308
-					$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>';
309
-					$form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
308
+					$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>';
309
+					$form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
310 310
                     </span></div>';
311 311
 				}
312 312
 				/**********************************************************************************/
313 313
 				else if ($fieldvalue[1] == 'PASSWORD') {
314 314
 					if (isset($this->CI->input->post))
315
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
315
+						$fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
316 316
 					else
317
-						$fieldvalue[2]['value'] = ($values) ?@$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
318
-					$form_contents.= form_password($fieldvalue[2]);
317
+						$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
318
+					$form_contents .= form_password($fieldvalue[2]);
319 319
 					$this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
320
-					$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>';
321
-					$form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
320
+					$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>';
321
+					$form_contents .= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
322 322
                     </span></div>';
323 323
 				} else if ($fieldvalue[2] == 'CHECKBOX') {
324 324
 					$OptionArray = array();
325 325
 
326
-					if(isset($fieldvalue[7]) && $fieldvalue[7] != '')
326
+					if (isset($fieldvalue[7]) && $fieldvalue[7] != '')
327 327
 					$OptionArray = call_user_func_array(array($this->CI->common, $fieldvalue[7]), array($fieldvalue[6]));
328
-					if (isset($this->CI->input->post)){
329
-						$fieldvalue[3]['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
328
+					if (isset($this->CI->input->post)) {
329
+						$fieldvalue[3]['value'] = ( ! $this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
330 330
 					}    
331 331
 					else
332 332
 					{
333
-						$fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1: 0) : @$fieldvalue[3]['value'];
333
+						$fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1 : 0) : @$fieldvalue[3]['value'];
334 334
 					}
335 335
 					if ($fieldvalue[3]['value'] == "1") {
336 336
 						$checked = true;
337 337
 					} else {
338 338
 						$checked = false;
339 339
 					};
340
-					if(isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != ""){
340
+					if (isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != "") {
341 341
 							
342
-						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked , $OptionArray);
343
-					}else{
344
-						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked ,$OptionArray);
342
+						 $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $checked, $OptionArray);
343
+					} else {
344
+						 $form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $checked, $OptionArray);
345 345
 					}
346 346
 				} else if ($fieldvalue[1] == 'TEXTAREA') {
347 347
 
348 348
 					if (isset($this->CI->input->post))
349
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
349
+						$fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
350 350
 					else
351 351
 						$fieldvalue[2]['value'] = ($values) ? $values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
352
-					$form_contents.= form_textarea($fieldvalue[2]);
352
+					$form_contents .= form_textarea($fieldvalue[2]);
353 353
 				}
354 354
 				else if ($fieldvalue[2] == 'RADIO') {
355 355
 
356
-					$form_contents.= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
356
+					$form_contents .= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
357 357
 				}
358
-				$form_contents.= '</li>';
358
+				$form_contents .= '</li>';
359 359
 			}
360 360
 
361
-			$form_contents.= '</ul>';
362
-			$form_contents.= '</div>';
363
-			$form_contents.= '</div>';
361
+			$form_contents .= '</ul>';
362
+			$form_contents .= '</div>';
363
+			$form_contents .= '</div>';
364 364
 			$i++;
365 365
 		}
366 366
 
367
-		$form_contents.= '<center><div class="col-md-12 margin-t-20 margin-b-20">';
367
+		$form_contents .= '<center><div class="col-md-12 margin-t-20 margin-b-20">';
368 368
 
369
-		$form_contents.= form_button($save);
369
+		$form_contents .= form_button($save);
370 370
 
371 371
 	if (isset($cancel)) {
372
-			$form_contents.= form_button($cancel);
372
+			$form_contents .= form_button($cancel);
373 373
 		}
374
-		$form_contents.= '</center></div>';
375
-		$form_contents.= form_fieldset_close();
376
-		$form_contents.= form_close();
377
-		$form_contents.= '</div>';
374
+		$form_contents .= '</center></div>';
375
+		$form_contents .= form_fieldset_close();
376
+		$form_contents .= form_close();
377
+		$form_contents .= '</div>';
378 378
 
379 379
 
380 380
 		return $form_contents;
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 
383 383
 	function build_serach_form($fields_array) {
384 384
 		$form_contents = '';
385
-		$form_contents.= '<div>';
386
-		$form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
385
+		$form_contents .= '<div>';
386
+		$form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
387 387
 		unset($fields_array['forms']);
388 388
 		$button_array = array();
389 389
 	/*******
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
 				$cancel = $fields_array['button_reset'];
397 397
 				unset($fields_array['button_reset']);
398 398
 			}
399
-		$button_search_delete='';
399
+		$button_search_delete = '';
400 400
 			if (isset($fields_array['button_search_delete'])) {
401 401
 				$button_search_delete = $fields_array['button_search_delete'];
402 402
 				unset($fields_array['button_search_delete']);
403 403
 			}
404
-			if(isset($fields_array['display_in'])){
405
-		  $display_in=$fields_array['display_in'];
404
+			if (isset($fields_array['display_in'])) {
405
+		  $display_in = $fields_array['display_in'];
406 406
 		  unset($fields_array['display_in']);
407 407
 		}
408 408
 		}
@@ -410,31 +410,31 @@  discard block
 block discarded – undo
410 410
 		$i = 1;
411 411
 		foreach ($fields_array as $fieldset_key => $form_fileds) {
412 412
 
413
-			$form_contents.= '<ul class="padding-15">';
414
-			$form_contents.= form_fieldset(gettext($fieldset_key),array('style' => 'font-weight:bold;'),"search");
413
+			$form_contents .= '<ul class="padding-15">';
414
+			$form_contents .= form_fieldset(gettext($fieldset_key), array('style' => 'font-weight:bold;'), "search");
415 415
 
416 416
 			foreach ($form_fileds as $fieldkey => $fieldvalue) {
417 417
 				if ($i == 0) {
418
-					$form_contents.= '<li class="col-md-12">';
418
+					$form_contents .= '<li class="col-md-12">';
419 419
 				}
420
-				$form_contents.= '<div class="col-md-3 no-padding">';
420
+				$form_contents .= '<div class="col-md-3 no-padding">';
421 421
 				if ($fieldvalue[1] == 'HIDDEN') {
422
-					$form_contents.= form_hidden($fieldvalue[2], $fieldvalue[3]);
422
+					$form_contents .= form_hidden($fieldvalue[2], $fieldvalue[3]);
423 423
 				} else {
424
-					$form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
424
+					$form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
425 425
 				}
426 426
 				if ($fieldvalue[1] == 'INPUT') {
427
-					$form_contents.= form_input($fieldvalue[2]);
427
+					$form_contents .= form_input($fieldvalue[2]);
428 428
 				}
429 429
 
430 430
 
431 431
 				if ($fieldvalue[2] == 'SELECT' || $fieldvalue[5] == '1') {
432 432
 			  
433 433
 					if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
434
-						$str = $fieldvalue[7] . "," . $fieldvalue[8];
434
+						$str = $fieldvalue[7].",".$fieldvalue[8];
435 435
 
436 436
 						$drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
437
-						$form_contents.=form_dropdown_all(gettext($fieldvalue[1]), $drp_array, '');
437
+						$form_contents .= form_dropdown_all(gettext($fieldvalue[1]), $drp_array, '');
438 438
 					} else {
439 439
 
440 440
 						if ($fieldvalue[1] == 'INPUT') {
@@ -442,54 +442,54 @@  discard block
 block discarded – undo
442 442
 						}
443 443
 			
444 444
 						$drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
445
-						$form_contents.=form_dropdown_all_search(gettext($fieldvalue[1]), $drp_array, '');
445
+						$form_contents .= form_dropdown_all_search(gettext($fieldvalue[1]), $drp_array, '');
446 446
 					}
447 447
 				} else if ($fieldvalue[1] == 'PASSWORD') {
448
-					$form_contents.= form_password($fieldvalue[2]);
448
+					$form_contents .= form_password($fieldvalue[2]);
449 449
 				} else if ($fieldvalue[2] == 'CHECKBOX') {
450
-					$form_contents.= form_checkbox(gettext($fieldvalue[1]), $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
450
+					$form_contents .= form_checkbox(gettext($fieldvalue[1]), $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
451 451
 				}
452
-				$form_contents.= '</div>';
452
+				$form_contents .= '</div>';
453 453
 				if ($i % 5 == 0) {
454
-					$form_contents.= '</li>';
454
+					$form_contents .= '</li>';
455 455
 					$i = 0;
456 456
 				}
457 457
 				$i++;
458 458
 			}
459 459
 		}
460
-		$form_contents.= '<div class="col-md-12 margin-t-20 margin-b-20">';
461
-		$form_contents.= form_button($cancel);
462
-		$form_contents.= form_button($save);
463
-		if(!empty($display_in)){
464
-			$form_contents.="<div class='col-md-5 pull-right'>";
465
-			$form_contents.="<div class='col-md-3'></div>";
466
-			$extra_parameters['class']=$display_in['label_class'];
467
-			$extra_parameters['style']=$display_in['label_style'];
468
-			$form_contents.=form_label($display_in['content'], "",$extra_parameters);
469
-			$drp_array = call_user_func_array(array($this->CI->common,$display_in['function']),array());
470
-			$extra_parameters['class']=$display_in['dropdown_class'];
471
-			$extra_parameters['style']=$display_in['dropdown_style'];
472
-			$form_contents.=form_dropdown_all_search($display_in, $drp_array, '',$extra_parameters);
473
-			$form_contents.="</div>";
460
+		$form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">';
461
+		$form_contents .= form_button($cancel);
462
+		$form_contents .= form_button($save);
463
+		if ( ! empty($display_in)) {
464
+			$form_contents .= "<div class='col-md-5 pull-right'>";
465
+			$form_contents .= "<div class='col-md-3'></div>";
466
+			$extra_parameters['class'] = $display_in['label_class'];
467
+			$extra_parameters['style'] = $display_in['label_style'];
468
+			$form_contents .= form_label($display_in['content'], "", $extra_parameters);
469
+			$drp_array = call_user_func_array(array($this->CI->common, $display_in['function']), array());
470
+			$extra_parameters['class'] = $display_in['dropdown_class'];
471
+			$extra_parameters['style'] = $display_in['dropdown_style'];
472
+			$form_contents .= form_dropdown_all_search($display_in, $drp_array, '', $extra_parameters);
473
+			$form_contents .= "</div>";
474 474
 		}
475
-		if(isset($button_search_delete) && $button_search_delete != ''){
476
-	  $form_contents.= form_button($button_search_delete);
475
+		if (isset($button_search_delete) && $button_search_delete != '') {
476
+	  $form_contents .= form_button($button_search_delete);
477 477
 		}
478
-		$form_contents.='<div class="col-md-12 no-padding margin-t-15" style="">
478
+		$form_contents .= '<div class="col-md-12 no-padding margin-t-15" style="">
479 479
 		<div class="pull-right btn-close" id="global_clearsearch_filter">Close</div> 
480 480
 	</div>';
481
-		$form_contents.= '</ul>';        
482
-		$form_contents.= '</div>';
483
-		$form_contents.= form_fieldset_close();
484
-		$form_contents.= form_close();
485
-		$form_contents.= '</div>';
481
+		$form_contents .= '</ul>';        
482
+		$form_contents .= '</div>';
483
+		$form_contents .= form_fieldset_close();
484
+		$form_contents .= form_close();
485
+		$form_contents .= '</div>';
486 486
 
487 487
 		return $form_contents;
488 488
 	}
489 489
 	function build_batchupdate_form($fields_array) {
490 490
 		$form_contents = '';
491
-		$form_contents.= '<div >';
492
-		$form_contents.= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
491
+		$form_contents .= '<div >';
492
+		$form_contents .= form_open($fields_array['forms'][0], $fields_array['forms'][1]);
493 493
 		unset($fields_array['forms']);
494 494
 		$button_array = array();
495 495
 		if (isset($fields_array['button_search']) || isset($fields_array['button_reset'])) {
@@ -503,69 +503,69 @@  discard block
 block discarded – undo
503 503
 		$i = 1;
504 504
 		foreach ($fields_array as $fieldset_key => $form_fileds) {
505 505
 
506
-			$form_contents.= '<ul>';
507
-			$form_contents.= form_fieldset(gettext($fieldset_key), array('style' => 'margin-left:-22px;font-weight:bold;'));
506
+			$form_contents .= '<ul>';
507
+			$form_contents .= form_fieldset(gettext($fieldset_key), array('style' => 'margin-left:-22px;font-weight:bold;'));
508 508
 			foreach ($form_fileds as $fieldkey => $fieldvalue) {
509 509
 				if ($i == 0) {
510
-					$form_contents.= '<li>';
510
+					$form_contents .= '<li>';
511 511
 				}
512
-				$form_contents.= '<div class="col-md-4 no-padding">';
512
+				$form_contents .= '<div class="col-md-4 no-padding">';
513 513
 				if ($fieldvalue[1] == 'HIDDEN') {
514
-					$form_contents.= form_hidden($fieldvalue[2], $fieldvalue[3]);
514
+					$form_contents .= form_hidden($fieldvalue[2], $fieldvalue[3]);
515 515
 				} else {
516
-					$form_contents.= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
516
+					$form_contents .= form_label(gettext($fieldvalue[0]), "", array("class" => "search_label col-md-12 no-padding"));
517 517
 				}
518 518
 				if ($fieldvalue[2] == 'SELECT' || $fieldvalue[5] == '1') {
519 519
 					if ($fieldvalue[7] != '' && $fieldvalue[8] != '') {
520
-						$str = $fieldvalue[7] . "," . $fieldvalue[8];
521
-						if(is_array($fieldvalue[13])){
520
+						$str = $fieldvalue[7].",".$fieldvalue[8];
521
+						if (is_array($fieldvalue[13])) {
522 522
 							$drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[14]), array($fieldvalue[13]));
523
-							$form_contents.=form_dropdown($fieldvalue[13], $drp_array, '');
523
+							$form_contents .= form_dropdown($fieldvalue[13], $drp_array, '');
524 524
 						}
525 525
 						/**
526 526
   		        ASTPP  3.0 
527 527
    		        Reseller Batch Update
528 528
 						 **/ 
529
-						if($fieldvalue[10] == 'set_status'){
530
-			$drp_array =array('0'=>'Active','1'=>'Inactive');
529
+						if ($fieldvalue[10] == 'set_status') {
530
+			$drp_array = array('0'=>'Active', '1'=>'Inactive');
531 531
 			}
532 532
 			/************************************************************/
533
-			else{
534
-						$drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));}
535
-						$form_contents.=form_dropdown_all($fieldvalue[1], $drp_array, '');
533
+			else {
534
+						$drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12])); }
535
+						$form_contents .= form_dropdown_all($fieldvalue[1], $drp_array, '');
536 536
 					} else {
537 537
 						if ($fieldvalue[1] == 'INPUT') {
538 538
 							$drp_name = $fieldvalue[6];
539 539
 						}
540 540
 						$drp_array = call_user_func_array(array($this->CI->common, $fieldvalue[10]), array($fieldvalue[9]));
541
-						$form_contents.=form_dropdown($drp_name, $drp_array, '');
541
+						$form_contents .= form_dropdown($drp_name, $drp_array, '');
542 542
 					}
543 543
 				}
544 544
 				if ($fieldvalue[1] == 'INPUT') {
545
-					$form_contents.= form_input($fieldvalue[2]);
545
+					$form_contents .= form_input($fieldvalue[2]);
546 546
 				} else if ($fieldvalue[2] == 'CHECKBOX') {
547
-					$form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
547
+					$form_contents .= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
548 548
 				}
549
-				$form_contents.= '</div>';
549
+				$form_contents .= '</div>';
550 550
 				if ($i % 5 == 0) {
551
-					$form_contents.= '</li>';
551
+					$form_contents .= '</li>';
552 552
 					$i = 0;
553 553
 				}
554 554
 				$i++;
555 555
 			}
556 556
 		}
557 557
 
558
-		$form_contents.= '</ul>';
559
-		$form_contents.= '<div class="col-md-12 margin-t-20 margin-b-20">';
558
+		$form_contents .= '</ul>';
559
+		$form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">';
560 560
 
561
-		$form_contents.= form_button($cancel);
562
-		$form_contents.= form_button($save);
563
-		$form_contents.='<div class="col-md-12 no-padding margin-t-15" style="margin-bottom:10px; !important">
561
+		$form_contents .= form_button($cancel);
562
+		$form_contents .= form_button($save);
563
+		$form_contents .= '<div class="col-md-12 no-padding margin-t-15" style="margin-bottom:10px; !important">
564 564
 						<div class="pull-right btn-close" id="global_clearbatchupdate_filter">Close</div></div>';
565
-		$form_contents.= form_fieldset_close();
566
-		$form_contents.= form_close();
567
-		$form_contents.= '</div>';
568
-		$form_contents.= '</div>';
565
+		$form_contents .= form_fieldset_close();
566
+		$form_contents .= form_close();
567
+		$form_contents .= '</div>';
568
+		$form_contents .= '</div>';
569 569
 
570 570
 		return $form_contents;
571 571
 	}
@@ -597,21 +597,21 @@  discard block
 block discarded – undo
597 597
                 ASTPP  3.0 
598 598
                 For Edit on Account number or name
599 599
             */
600
-		$row_id = isset($row['id']) ? $row["id"]: '';
600
+		$row_id = isset($row['id']) ? $row["id"] : '';
601 601
 /*****************************/
602 602
 				foreach ($grid_fields as $field_key => $field_arr) {
603 603
 /**
604 604
 ASTPP  3.0 
605 605
 For Edit on Account number or name
606 606
 **/
607
-			 $Actionkey = array_search(gettext('Action'), $this->CI->common->array_column($grid_fields,0));
607
+			 $Actionkey = array_search(gettext('Action'), $this->CI->common->array_column($grid_fields, 0));
608 608
 /*********************************/
609 609
 					if ($field_arr[2] != "") {
610 610
 						if ($field_arr[3] != "") {
611
-						   if($field_arr[2]=="status"){
611
+						   if ($field_arr[2] == "status") {
612 612
 							$row['id'] = $row_id;
613 613
 							$jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
614
-			   }else{
614
+			   } else {
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[$field_arr[2]]));
616 616
 			   }
617 617
 
@@ -620,53 +620,53 @@  discard block
 block discarded – undo
620 620
 For Edit on Account number or name
621 621
 **/
622 622
 				$row[$field_arr[2]] = $jsn_tmp[$field_key];
623
-			} if(array_search("EDITABLE", $field_arr)){
623
+			} if (array_search("EDITABLE", $field_arr)) {
624 624
 				$ActionArr = $grid_fields[$Actionkey];
625
-				if($ActionArr[5]->EDIT->url =="accounts/customer_edit/" || $ActionArr[5]->EDIT->url =="accounts/provider_edit/"){
626
-				   $ActionArr[5]->EDIT->url=$row['type']==0 ?  "accounts/customer_edit/"  : "accounts/provider_edit/";
625
+				if ($ActionArr[5]->EDIT->url == "accounts/customer_edit/" || $ActionArr[5]->EDIT->url == "accounts/provider_edit/") {
626
+				   $ActionArr[5]->EDIT->url = $row['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/";
627 627
 				}
628
-				if($ActionArr[5]->EDIT->url =="accounts/admin_edit/" || $ActionArr[5]->EDIT->url =="accounts/subadmin_edit/"){
629
-				   $ActionArr[5]->EDIT->url=$row['type']==4 ?  "accounts/subadmin_edit/"  : "accounts/admin_edit/";
628
+				if ($ActionArr[5]->EDIT->url == "accounts/admin_edit/" || $ActionArr[5]->EDIT->url == "accounts/subadmin_edit/") {
629
+				   $ActionArr[5]->EDIT->url = $row['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/";
630 630
 				}
631 631
 				$acctype = "";
632
-				if(isset($row["type"]) && ($row["type"] == '0' || $row["type"] == '1' || $row["type"] == '3')){
633
-					$acctype = (isset($row["posttoexternal"]) && $row["posttoexternal"] != '')? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("","",$row["posttoexternal"])."</span>":"";
632
+				if (isset($row["type"]) && ($row["type"] == '0' || $row["type"] == '1' || $row["type"] == '3')) {
633
+					$acctype = (isset($row["posttoexternal"]) && $row["posttoexternal"] != '') ? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("", "", $row["posttoexternal"])."</span>" : "";
634 634
 				}
635 635
 
636
-				$fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
637
-				if($acctype != ''){
636
+				$fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT, $row[$field_arr[2]], $row["id"]);
637
+				if ($acctype != '') {
638 638
 					$jsn_tmp[$field_key] = $fieldstr."<br/>".$acctype;
639
-				}else{
639
+				} else {
640 640
 					$jsn_tmp[$field_key] = $fieldstr;
641 641
 				}
642 642
 			    
643 643
 
644 644
 /*********************************/
645
-			  }else {
645
+			  } else {
646 646
 							$jsn_tmp[$field_key] = $row[$field_arr[2]];
647 647
 				  }                  				
648 648
 			} else {
649 649
 				if ($field_arr[0] == gettext("Action")) {
650
-				if(isset($field_arr[5]) && isset($field_arr[5]->EDIT) && isset($field_arr[5]->DELETE)){
650
+				if (isset($field_arr[5]) && isset($field_arr[5]->EDIT) && isset($field_arr[5]->DELETE)) {
651 651
 		             
652
-					  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/'){
653
-					   if( $row['type'] == '0'|| strtolower($row['type']) == 'customer'){
654
-						$field_arr[5]->EDIT->url ='accounts/customer_edit/';
655
-						$field_arr[5]->DELETE->url ='accounts/customer_delete/';
652
+					  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/') {
653
+					   if ($row['type'] == '0' || strtolower($row['type']) == 'customer') {
654
+						$field_arr[5]->EDIT->url = 'accounts/customer_edit/';
655
+						$field_arr[5]->DELETE->url = 'accounts/customer_delete/';
656 656
 					   }
657
-					   if($row['type'] == 3 || strtolower($row['type']) == 'provider'){
658
-						$field_arr[5]->EDIT->url ='accounts/provider_edit/';
659
-						$field_arr[5]->DELETE->url ='accounts/provider_delete/';
657
+					   if ($row['type'] == 3 || strtolower($row['type']) == 'provider') {
658
+						$field_arr[5]->EDIT->url = 'accounts/provider_edit/';
659
+						$field_arr[5]->DELETE->url = 'accounts/provider_delete/';
660 660
 					   }
661 661
 					  }
662
-					  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/'){
663
-					   if($row['type'] == 2 || strtolower($row['type']) == 'administrator'){
664
-						$field_arr[5]->EDIT->url ='accounts/admin_edit/';
665
-						$field_arr[5]->DELETE->url ='accounts/admin_delete/';
662
+					  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/') {
663
+					   if ($row['type'] == 2 || strtolower($row['type']) == 'administrator') {
664
+						$field_arr[5]->EDIT->url = 'accounts/admin_edit/';
665
+						$field_arr[5]->DELETE->url = 'accounts/admin_delete/';
666 666
 					   }
667
-					   if($row['type'] == 4 || strtolower($row['type']) == 'sub admin'){
668
-						$field_arr[5]->EDIT->url ='accounts/subadmin_edit/';
669
-						$field_arr[5]->DELETE->url ='accounts/subadmin_delete/';
667
+					   if ($row['type'] == 4 || strtolower($row['type']) == 'sub admin') {
668
+						$field_arr[5]->EDIT->url = 'accounts/subadmin_edit/';
669
+						$field_arr[5]->DELETE->url = 'accounts/subadmin_delete/';
670 670
 					   }
671 671
 					}
672 672
 			   }
@@ -677,16 +677,16 @@  discard block
 block discarded – undo
677 677
 							$jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row_id);
678 678
 							/****************************************************************************/
679 679
 						}
680
-						elseif($field_arr[0] == gettext("Profile Action"))
680
+						elseif ($field_arr[0] == gettext("Profile Action"))
681 681
 						{
682
-						   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)){
682
+						   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)) {
683 683
 							}
684 684
 						   $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
685 685
                         
686 686
 						}
687 687
 						else {
688
-							$className = (isset($field_arr['9']) && $field_arr['9'] != '')?$field_arr['9']:"chkRefNos";
689
-							$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>';                        }
688
+							$className = (isset($field_arr['9']) && $field_arr['9'] != '') ? $field_arr['9'] : "chkRefNos";
689
+							$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 690
 					}
691 691
 				}
692 692
 				$json_data[] = array('cell' => $jsn_tmp);
@@ -700,20 +700,20 @@  discard block
 block discarded – undo
700 700
 		$json_data = array();
701 701
 		foreach ($query as $row) {
702 702
 			foreach ($grid_fields as $field_key => $field_arr) {
703
-				$row_id = isset($row['id']) ? $row["id"]: '';
703
+				$row_id = isset($row['id']) ? $row["id"] : '';
704 704
 /**
705 705
 ASTPP  3.0 
706 706
 For Edit on Account number or name
707 707
 **/
708
-		$Actionkey = array_search('Action',$this->CI->common->array_column($grid_fields,0)); 
708
+		$Actionkey = array_search('Action', $this->CI->common->array_column($grid_fields, 0)); 
709 709
 /*******************************/
710 710
 
711 711
 				if ($field_arr[2] != "") {
712 712
 					if ($field_arr[3] != "") {
713
-						 if($field_arr[2]=="status"){
713
+						 if ($field_arr[2] == "status") {
714 714
 							$row['id'] = $row_id;
715 715
 							$jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
716
-						 }else{
716
+						 } else {
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[$field_arr[2]]));
718 718
 						 }
719 719
 /**
@@ -721,17 +721,17 @@  discard block
 block discarded – undo
721 721
 For Edit on Account number or name
722 722
 **/
723 723
  			$row[$field_arr[2]] = $jsn_tmp[$field_key];
724
-					  } if(array_search("EDITABLE", $field_arr)){
724
+					  } if (array_search("EDITABLE", $field_arr)) {
725 725
 				$ActionArr = $grid_fields[$Actionkey];
726
-				if($ActionArr[5]->EDIT->url =="accounts/customer_edit/" || $ActionArr[5]->EDIT->url =="accounts/provider_edit/"){
727
-				   $ActionArr[5]->EDIT->url=$row['type']==0 ?  "accounts/customer_edit/"  : "accounts/provider_edit/";
726
+				if ($ActionArr[5]->EDIT->url == "accounts/customer_edit/" || $ActionArr[5]->EDIT->url == "accounts/provider_edit/") {
727
+				   $ActionArr[5]->EDIT->url = $row['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/";
728 728
 				}
729
-				if($ActionArr[5]->EDIT->url =="accounts/admin_edit/" || $ActionArr[5]->EDIT->url =="accounts/subadmin_edit/"){
730
-				   $ActionArr[5]->EDIT->url=$row['type']==4 ?  "accounts/subadmin_edit/"  : "accounts/admin_edit/";
729
+				if ($ActionArr[5]->EDIT->url == "accounts/admin_edit/" || $ActionArr[5]->EDIT->url == "accounts/subadmin_edit/") {
730
+				   $ActionArr[5]->EDIT->url = $row['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/";
731 731
 				}
732
-				$jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
732
+				$jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT, $row[$field_arr[2]], $row["id"]);
733 733
 /*******************************/
734
-			}else {
734
+			} else {
735 735
 						$jsn_tmp[$field_key] = isset($row[$field_arr[2]]) ? $row[$field_arr[2]] : "";
736 736
 					}
737 737
 				} else {
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 						$jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
740 740
 					}
741 741
 			  else {
742
-							$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>';
742
+							$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>';
743 743
 						}
744 744
 				}
745 745
 			}
Please login to merge, or discard this patch.
Braces   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  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 28
 /**
28 29
  * Dynamically build forms for display
@@ -137,10 +138,11 @@  discard block
 block discarded – undo
137 138
             foreach ($form_fileds as $fieldkey => $fieldvalue) {
138 139
                 $form_contents .= '<li class="col-md-12">';
139 140
                 if ($fieldvalue[1] == 'HIDDEN') {
140
-                    if (isset($this->CI->input->post))
141
-                        $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
142
-                    else
143
-                        $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
141
+                    if (isset($this->CI->input->post)) {
142
+                                            $fieldvalue[2]['value'] = ( ! $this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
143
+                    } else {
144
+                                            $fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : '') : (isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] : '');
145
+                    }
144 146
                     $form_contents .= form_hidden($fieldvalue[2]['name'], $fieldvalue[2]['value']);
145 147
                 } else {
146 148
 		      $validation_arr = array();
@@ -148,8 +150,7 @@  discard block
 block discarded – undo
148 150
 		        if ( ! empty($fieldvalue[3])) {
149 151
 		          $validation_arr = explode("|", $fieldvalue[3]);
150 152
 		        }
151
-		      }
152
-		      elseif ($fieldvalue[2] == 'SELECT') {
153
+		      } elseif ($fieldvalue[2] == 'SELECT') {
153 154
 
154 155
 		        if (is_array($fieldvalue[4])) {
155 156
 		          $validation_arr = explode("|", $fieldvalue[4]['rules']);
@@ -199,16 +200,16 @@  discard block
 block discarded – undo
199 200
 								
200 201
 								if(isset($fieldvalue[1]['name'])){
201 202
 									$fieldvalue_pass=$fieldvalue[1]['name'];
202
-								}else{
203
+								} else{
203 204
 									$fieldvalue_pass=$fieldvalue[1];
204 205
 								}
205 206
 								
206 207
 								$this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue[0], $fieldvalue[4]['rules']);
207
-							}else{
208
+							} else{
208 209
 								
209 210
 								if(isset($fieldvalue[1]['name'])){
210 211
 									$fieldvalue_pass=$fieldvalue[1]['name'];
211
-								}else{
212
+								} else{
212 213
 									$fieldvalue_pass=$fieldvalue[1];
213 214
 								}
214 215
 								
@@ -244,10 +245,11 @@  discard block
 block discarded – undo
244 245
 					/* For multi select code */
245 246
 					$str = $fieldvalue[7] . "," . $fieldvalue[8];
246 247
 
247
-					if (isset($this->CI->input->post))
248
-						$fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
249
-					else
250
-						$fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
248
+					if (isset($this->CI->input->post)) {
249
+											$fieldvalue['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[1] : $this->CI->input->post($fieldvalue[1]);
250
+					} else {
251
+											$fieldvalue['value'] = ($values) ? @$values[$fieldvalue[1]] : @$fieldvalue[1];
252
+					}
251 253
 
252 254
 					$drp_array = call_user_func_array(array($this->CI->db_model, $fieldvalue[10]), array($str, $fieldvalue[9], $fieldvalue[11], $fieldvalue[12]));
253 255
 					if ($fieldset_key === 'System Configuration Information') {
@@ -264,9 +266,9 @@  discard block
 block discarded – undo
264 266
 				} else if ($fieldvalue[1] == 'INPUT') {
265 267
 
266 268
 
267
-					if (isset($this->CI->input->post))
268
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? $fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
269
-					else{
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{
270 272
 						$fieldvalue[2]['value'] = ($values) ? (isset($values[$fieldvalue[2]['name']]) ? $values[$fieldvalue[2]['name']] : ''):(isset($fieldvalue[2]['value']) ? $fieldvalue[2]['value'] :'');
271 273
 					}    
272 274
 					$form_contents.= form_input($fieldvalue[2], 'readonly');
@@ -282,11 +284,11 @@  discard block
 block discarded – undo
282 284
                  * Image upload from invoice configuration code.
283 285
                  */
284 286
 				else if ($fieldvalue[1] == 'IMAGE') {
285
-					if (isset($this->CI->input->post))
286
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
287
-                       
288
-					else
289
-						$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
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']);
289
+					} else {
290
+											$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
291
+					}
290 292
 						$fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
291 293
 					$form_contents.= form_image($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
292 294
 						 $form_contents.=@$fieldvalue[6];
@@ -294,13 +296,12 @@  discard block
 block discarded – undo
294 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>';
295 297
 					$form_contents.= '<span class="popup_error error  no-padding" id="'.$fieldvalue[2]['name'].'_error">
296 298
                     </span></div>';
297
-				}
298
-				else if ($fieldvalue[1] == 'DEL_BUTTON') {
299
-					if (isset($this->CI->input->post))
300
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
301
-                       
302
-					else
303
-						$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
299
+				} else if ($fieldvalue[1] == 'DEL_BUTTON') {
300
+					if (isset($this->CI->input->post)) {
301
+											$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
302
+					} else {
303
+											$fieldvalue[2]['value'] = ($values) ? @$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
304
+					}
304 305
 						$fieldvalue[2]['style'] = isset($fieldvalue[2]['style']) ? $fieldvalue[2]['style'] : "";
305 306
 					$form_contents.= form_img_delete($fieldvalue[2], 'readonly',$fieldvalue[2]['style']);
306 307
 						 $form_contents.=@$fieldvalue[6];
@@ -311,10 +312,11 @@  discard block
 block discarded – undo
311 312
 				}
312 313
 				/**********************************************************************************/
313 314
 				else if ($fieldvalue[1] == 'PASSWORD') {
314
-					if (isset($this->CI->input->post))
315
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
316
-					else
317
-						$fieldvalue[2]['value'] = ($values) ?@$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
315
+					if (isset($this->CI->input->post)) {
316
+											$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
317
+					} else {
318
+											$fieldvalue[2]['value'] = ($values) ?@$values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
319
+					}
318 320
 					$form_contents.= form_password($fieldvalue[2]);
319 321
 					$this->CI->form_validation->set_rules($fieldvalue[2]['name'], $fieldvalue[0], $fieldvalue[3]);
320 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,12 +325,12 @@  discard block
 block discarded – undo
323 325
 				} else if ($fieldvalue[2] == 'CHECKBOX') {
324 326
 					$OptionArray = array();
325 327
 
326
-					if(isset($fieldvalue[7]) && $fieldvalue[7] != '')
327
-					$OptionArray = call_user_func_array(array($this->CI->common, $fieldvalue[7]), array($fieldvalue[6]));
328
+					if(isset($fieldvalue[7]) && $fieldvalue[7] != '') {
329
+										$OptionArray = call_user_func_array(array($this->CI->common, $fieldvalue[7]), array($fieldvalue[6]));
330
+					}
328 331
 					if (isset($this->CI->input->post)){
329 332
 						$fieldvalue[3]['value'] = (!$this->CI->input->post($fieldvalue[1])) ? @$fieldvalue[3]['value'] : $this->CI->input->post($fieldvalue[1]);
330
-					}    
331
-					else
333
+					} else
332 334
 					{
333 335
 						$fieldvalue[3]['value'] = ($values) ? (isset($values[$fieldvalue[1]]) && $values[$fieldvalue[1]] ? 1: 0) : @$fieldvalue[3]['value'];
334 336
 					}
@@ -340,18 +342,18 @@  discard block
 block discarded – undo
340 342
 					if(isset($fieldvalue[3]['table_name']) && $fieldvalue[3]['table_name'] != ""){
341 343
 							
342 344
 						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked , $OptionArray);
343
-					}else{
345
+					} else{
344 346
 						 $form_contents.= form_checkbox($fieldvalue[1], $fieldvalue[3]['value'],$checked ,$OptionArray);
345 347
 					}
346 348
 				} else if ($fieldvalue[1] == 'TEXTAREA') {
347 349
 
348
-					if (isset($this->CI->input->post))
349
-						$fieldvalue[2]['value'] = (!$this->CI->input->post($fieldvalue[2]['name'])) ? @$fieldvalue[2]['value'] : $this->CI->input->post($fieldvalue[2]['name']);
350
-					else
351
-						$fieldvalue[2]['value'] = ($values) ? $values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
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']);
352
+					} else {
353
+											$fieldvalue[2]['value'] = ($values) ? $values[$fieldvalue[2]['name']] : @$fieldvalue[2]['value'];
354
+					}
352 355
 					$form_contents.= form_textarea($fieldvalue[2]);
353
-				}
354
-				else if ($fieldvalue[2] == 'RADIO') {
356
+				} else if ($fieldvalue[2] == 'RADIO') {
355 357
 
356 358
 					$form_contents.= form_radio($fieldvalue[1], $fieldvalue[3]['value'], $fieldvalue[3]['checked']);
357 359
 				}
@@ -581,8 +583,9 @@  discard block
 block discarded – undo
581 583
 		$json_data["json_paging"]['total'] = $config['total_rows'];
582 584
 		$perpage = $config['per_page'];
583 585
 		$start = ($page_no - 1) * $perpage;
584
-		if ($start < 0)
585
-			$start = 0;
586
+		if ($start < 0) {
587
+					$start = 0;
588
+		}
586 589
 		$json_data["paging"]['start'] = $start;
587 590
 		$json_data["paging"]['page_no'] = $perpage;
588 591
 		return $json_data;
@@ -611,7 +614,7 @@  discard block
 block discarded – undo
611 614
 						   if($field_arr[2]=="status"){
612 615
 							$row['id'] = $row_id;
613 616
 							$jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
614
-			   }else{
617
+			   } else{
615 618
 							$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]]));
616 619
 			   }
617 620
 
@@ -636,13 +639,13 @@  discard block
 block discarded – undo
636 639
 				$fieldstr = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
637 640
 				if($acctype != ''){
638 641
 					$jsn_tmp[$field_key] = $fieldstr."<br/>".$acctype;
639
-				}else{
642
+				} else{
640 643
 					$jsn_tmp[$field_key] = $fieldstr;
641 644
 				}
642 645
 			    
643 646
 
644 647
 /*********************************/
645
-			  }else {
648
+			  } else {
646 649
 							$jsn_tmp[$field_key] = $row[$field_arr[2]];
647 650
 				  }                  				
648 651
 			} else {
@@ -676,15 +679,13 @@  discard block
 block discarded – undo
676 679
 */			   
677 680
 							$jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row_id);
678 681
 							/****************************************************************************/
679
-						}
680
-						elseif($field_arr[0] == gettext("Profile Action"))
682
+						} elseif($field_arr[0] == gettext("Profile Action"))
681 683
 						{
682 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)){
683 685
 							}
684 686
 						   $jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
685 687
                         
686
-						}
687
-						else {
688
+						} else {
688 689
 							$className = (isset($field_arr['9']) && $field_arr['9'] != '')?$field_arr['9']:"chkRefNos";
689 690
 							$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 691
 					}
@@ -713,7 +714,7 @@  discard block
 block discarded – undo
713 714
 						 if($field_arr[2]=="status"){
714 715
 							$row['id'] = $row_id;
715 716
 							$jsn_tmp[$field_key] = call_user_func_array(array($this->CI->common, $field_arr[5]), array($field_arr[3], $field_arr[4], $row));
716
-						 }else{
717
+						 } else{
717 718
 							$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]]));
718 719
 						 }
719 720
 /**
@@ -731,14 +732,13 @@  discard block
 block discarded – undo
731 732
 				}
732 733
 				$jsn_tmp[$field_key] = $this->CI->common->build_custome_edit_button($ActionArr[5]->EDIT,$row[$field_arr[2]],$row["id"]);
733 734
 /*******************************/
734
-			}else {
735
+			} else {
735 736
 						$jsn_tmp[$field_key] = isset($row[$field_arr[2]]) ? $row[$field_arr[2]] : "";
736 737
 					}
737 738
 				} else {
738 739
 					if ($field_arr[0] == "Action") {
739 740
 						$jsn_tmp[$field_key] = $this->CI->common->get_action_buttons($field_arr[5], $row["id"]);
740
-					}
741
-			  else {
741
+					} else {
742 742
 							$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>';
743 743
 						}
744 744
 				}
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/common.php 3 patches
Indentation   +1327 added lines, -1327 removed lines patch added patch discarded remove patch
@@ -23,466 +23,466 @@  discard block
 block discarded – undo
23 23
 ###############################################################################
24 24
 
25 25
 if ( ! defined('BASEPATH'))
26
-    exit('No direct script access allowed');
26
+	exit('No direct script access allowed');
27 27
 
28 28
 /**
29 29
  * Dynamically build forms for display
30 30
  */
31 31
 class common {
32 32
 
33
-    protected $CI; // codeigniter
33
+	protected $CI; // codeigniter
34 34
 
35
-    function __construct($library_name = '') {
35
+	function __construct($library_name = '') {
36 36
 
37
-        $this->CI = & get_instance();
38
-        $this->CI->load->library("timezone");
39
-        $this->CI->load->model('db_model');
40
-        $this->CI->load->library('email');
41
-        $this->CI->load->library('session');
42
-    }
37
+		$this->CI = & get_instance();
38
+		$this->CI->load->library("timezone");
39
+		$this->CI->load->model('db_model');
40
+		$this->CI->load->library('email');
41
+		$this->CI->load->library('session');
42
+	}
43 43
 
44 44
 // __construct
45
-    /**
46
-     * adds raw html to the field array
47
-     */
48
-    function generate_password() {
49
-        $pass = substr(md5(rand(0, 1000000000)), 0, common_model::$global_config['system_config']['pinlength']);
50
-        return $pass;
51
-    }
52
-
53
-    function find_uniq_rendno($size = '', $field = '', $tablename = '') {
54
-
55
-        if ($tablename != '') {
56
-            $accounttype_array = array();
57
-            $uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
58
-            $where = array($field => $uname);
59
-            $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
60
-            $acc_result = $acc_result->result();
61
-            while ($acc_result[0]->count != 0) {
62
-                $uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
63
-                $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
64
-            }
65
-        } else {
66
-            $uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
67
-        }
68
-        return $uname;
69
-    }
70
-
71
-    function find_uniq_rendno_customer($size = '', $field = '', $tablename = '') {
72
-        if ($tablename != '') {
73
-            $accounttype_array = array();
74
-            $uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
75
-            $where = array($field => $uname);
76
-            $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
77
-            $acc_result = $acc_result->result();
78
-            while ($acc_result[0]->count != 0) {
79
-                $uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
80
-                $acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
81
-            }
82
-        } else {
83
-            $uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
84
-        }
85
-        $start_prifix_value = common_model::$global_config['system_config']['startingdigit'];
86
-        if ($tablename == 'accounts' && $start_prifix_value != 0) {
87
-            $length = strlen($start_prifix_value);
88
-            $uname = substr($uname, $length);
89
-            $uname = $start_prifix_value.$uname;
90
-        }
91
-        return $uname;
92
-    }
93
-
94
-    /**
95
-     * @param string $length
96
-     */
97
-    function random_string($length) {
98
-        $chars = "1234567890"; //length:36
99
-        $final_rand = '';
100
-        for ($i = 0; $i < $length; $i++) {
101
-            $final_rand .= $chars[rand(0, strlen($chars) - 1)];
102
-        }
103
-        return $final_rand;
104
-    }
105
-
106
-    function find_uniq_rendno_accno($length = '', $field = '', $tablename = '', $default, $creation_count) {
107
-        $number = array();
108
-        $j = 0;
109
-
110
-        $total_count = pow(10, $length);
111
-        for ($i = 1; $i <= $total_count; $i++) {
112
-
113
-            $flag = false;
114
-            $uname = $this->random_string($length);
115
-            $uname = strtolower($uname);
116
-            if (isset($default))
117
-                $uname = $default.$uname;
118
-            if ( ! in_array($uname, $number)) {
119
-                $where = array($field => $uname);
120
-                $acc_result = $this->CI->db_model->getSelect('Count(id) as count', $tablename, $where);
121
-                $acc_result = $acc_result->result_array();
122
-                if ($acc_result[0]['count'] == 0 && ! in_array($uname, $number)) {
123
-                    $number[] = $uname;
124
-                    $j++;
125
-                }
126
-                if ($j == $creation_count) {
127
-                    break;
128
-                }
129
-            } else {
130
-                $total_count++;
131
-            }
132
-        }
133
-        return $number;
134
-    }
135
-
136
-    /**
137
-     * @param string $select
138
-     * @param string $table
139
-     */
140
-    function get_field_count($select, $table, $where) {
45
+	/**
46
+	 * adds raw html to the field array
47
+	 */
48
+	function generate_password() {
49
+		$pass = substr(md5(rand(0, 1000000000)), 0, common_model::$global_config['system_config']['pinlength']);
50
+		return $pass;
51
+	}
52
+
53
+	function find_uniq_rendno($size = '', $field = '', $tablename = '') {
54
+
55
+		if ($tablename != '') {
56
+			$accounttype_array = array();
57
+			$uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
58
+			$where = array($field => $uname);
59
+			$acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
60
+			$acc_result = $acc_result->result();
61
+			while ($acc_result[0]->count != 0) {
62
+				$uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
63
+				$acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
64
+			}
65
+		} else {
66
+			$uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
67
+		}
68
+		return $uname;
69
+	}
70
+
71
+	function find_uniq_rendno_customer($size = '', $field = '', $tablename = '') {
72
+		if ($tablename != '') {
73
+			$accounttype_array = array();
74
+			$uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
75
+			$where = array($field => $uname);
76
+			$acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
77
+			$acc_result = $acc_result->result();
78
+			while ($acc_result[0]->count != 0) {
79
+				$uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
80
+				$acc_result = $this->CI->db_model->getSelect('Count(*) as count', $tablename, $where);
81
+			}
82
+		} else {
83
+			$uname = rand(pow(10, $size - 1), pow(10, $size) - 1);
84
+		}
85
+		$start_prifix_value = common_model::$global_config['system_config']['startingdigit'];
86
+		if ($tablename == 'accounts' && $start_prifix_value != 0) {
87
+			$length = strlen($start_prifix_value);
88
+			$uname = substr($uname, $length);
89
+			$uname = $start_prifix_value.$uname;
90
+		}
91
+		return $uname;
92
+	}
93
+
94
+	/**
95
+	 * @param string $length
96
+	 */
97
+	function random_string($length) {
98
+		$chars = "1234567890"; //length:36
99
+		$final_rand = '';
100
+		for ($i = 0; $i < $length; $i++) {
101
+			$final_rand .= $chars[rand(0, strlen($chars) - 1)];
102
+		}
103
+		return $final_rand;
104
+	}
105
+
106
+	function find_uniq_rendno_accno($length = '', $field = '', $tablename = '', $default, $creation_count) {
107
+		$number = array();
108
+		$j = 0;
109
+
110
+		$total_count = pow(10, $length);
111
+		for ($i = 1; $i <= $total_count; $i++) {
112
+
113
+			$flag = false;
114
+			$uname = $this->random_string($length);
115
+			$uname = strtolower($uname);
116
+			if (isset($default))
117
+				$uname = $default.$uname;
118
+			if ( ! in_array($uname, $number)) {
119
+				$where = array($field => $uname);
120
+				$acc_result = $this->CI->db_model->getSelect('Count(id) as count', $tablename, $where);
121
+				$acc_result = $acc_result->result_array();
122
+				if ($acc_result[0]['count'] == 0 && ! in_array($uname, $number)) {
123
+					$number[] = $uname;
124
+					$j++;
125
+				}
126
+				if ($j == $creation_count) {
127
+					break;
128
+				}
129
+			} else {
130
+				$total_count++;
131
+			}
132
+		}
133
+		return $number;
134
+	}
135
+
136
+	/**
137
+	 * @param string $select
138
+	 * @param string $table
139
+	 */
140
+	function get_field_count($select, $table, $where) {
141 141
 //        echo $select."=====".$table."===".$where;
142
-        if (is_array($where)) {
143
-            $where = $where;
144
-        } else {
145
-            $where = array($select => $where);
146
-        }
147
-        $field_name = $this->CI->db_model->countQuery($select, $table, $where);
148
-        if (isset($field_name) && ! empty($field_name)) {
149
-            return $field_name;
150
-        } else {
151
-            return "0";
152
-        }
153
-    }
154
-
155
-    /**
156
-     * @param string $select
157
-     * @param string $table
158
-     */
159
-    function get_field_name($select, $table, $where) {
160
-        if (is_array($where)) {
161
-            $where = $where;
162
-        } else {
163
-            $where = array("id" => $where);
164
-        }
165
-        $field_name = $this->CI->db_model->getSelect($select, $table, $where);
166
-        $field_name = $field_name->result();
167
-        if (isset($field_name) && ! empty($field_name)) {
168
-            return $field_name[0]->$select;
169
-        } else {
170
-            return "";
171
-        }
172
-    }
173
-
174
-    /**
175
-     * @param string $select
176
-     * @param string $table
177
-     */
178
-    function get_field_name_coma_new($select, $table, $where) {
179
-        $value = '';
180
-        if (is_array($where)) {
181
-            $where = $where;
182
-        } else {
183
-            $where = explode(',', $where);
184
-        }
185
-        $select1 = explode(',', $select);
186
-        for ($i = 0; $i < count($where); $i++) {
187
-            $where_in = array("id" => $where[$i]);
188
-
189
-            $field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
190
-            $field_name = $field_name->result();
191
-            if (isset($field_name) && ! empty($field_name)) {
192
-                foreach ($select1 as $sel) {
193
-                    if ($sel == 'number') {
194
-                        $value .= "(".$field_name[0]->$sel.")";
195
-                    } else {
196
-                        $value .= $field_name[0]->$sel." ";
197
-                    }
198
-                }
199
-            } else {
200
-                $value = "";
201
-            }
202
-        }
203
-        return rtrim($value, ',');
204
-    }
205
-
206
-    function check_did_avl($select, $table, $where) {
207
-        $accountinfo = $this->CI->session->userdata('accountinfo');
208
-        $flag_status = "";
209
-        $where = array("number" => $where);
210
-        $field_name = $this->CI->db_model->getSelect("id,accountid,parent_id", 'dids', $where);
211
-        $field_name = $field_name->result();
212
-        if (isset($field_name) && ! empty($field_name)) {
213
-            if (isset($field_name[0]) && $accountinfo['type'] != 1) {
214
-                if ($field_name[0]->accountid != 0 && $field_name[0]->parent_id == 0) {
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(C)<span></a>";
216
-                } else if ($field_name[0]->parent_id != 0) {
217
-                    $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>";
218
-                } else {
219
-                    $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
220
-                }
221
-            } else {
222
-                $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
223
-                $where = array("note" => $field_name[0]->number, 'parent_id' => $reseller_id);
224
-                $field_name_re = $this->CI->db_model->getSelect("reseller_id", 'reseller_pricing', $where);
225
-                $field_name_re = $field_name_re->result();
226
-
227
-                if (isset($field_name_re) && ! empty($field_name_re)) {
228
-                    $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>";
229
-                } else {
230
-                    $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
231
-                }
232
-            }
233
-        } else {
234
-            $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
235
-        }
236
-        return $flag_status;
237
-    }
238
-    function check_did_avl_export($number) {
239
-      $this->CI->db->where('number', $number);
240
-      $this->CI->db->select('id,accountid,parent_id');
241
-      $status = null;
242
-      $did_info = (array)$this->CI->db->get('dids')->first_row();
243
-      $accountinfo = $this->CI->session->userdata('accountinfo');
244
-      if ($did_info['accountid'] == 0 && $did_info['parent_id'] == 0) {
142
+		if (is_array($where)) {
143
+			$where = $where;
144
+		} else {
145
+			$where = array($select => $where);
146
+		}
147
+		$field_name = $this->CI->db_model->countQuery($select, $table, $where);
148
+		if (isset($field_name) && ! empty($field_name)) {
149
+			return $field_name;
150
+		} else {
151
+			return "0";
152
+		}
153
+	}
154
+
155
+	/**
156
+	 * @param string $select
157
+	 * @param string $table
158
+	 */
159
+	function get_field_name($select, $table, $where) {
160
+		if (is_array($where)) {
161
+			$where = $where;
162
+		} else {
163
+			$where = array("id" => $where);
164
+		}
165
+		$field_name = $this->CI->db_model->getSelect($select, $table, $where);
166
+		$field_name = $field_name->result();
167
+		if (isset($field_name) && ! empty($field_name)) {
168
+			return $field_name[0]->$select;
169
+		} else {
170
+			return "";
171
+		}
172
+	}
173
+
174
+	/**
175
+	 * @param string $select
176
+	 * @param string $table
177
+	 */
178
+	function get_field_name_coma_new($select, $table, $where) {
179
+		$value = '';
180
+		if (is_array($where)) {
181
+			$where = $where;
182
+		} else {
183
+			$where = explode(',', $where);
184
+		}
185
+		$select1 = explode(',', $select);
186
+		for ($i = 0; $i < count($where); $i++) {
187
+			$where_in = array("id" => $where[$i]);
188
+
189
+			$field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
190
+			$field_name = $field_name->result();
191
+			if (isset($field_name) && ! empty($field_name)) {
192
+				foreach ($select1 as $sel) {
193
+					if ($sel == 'number') {
194
+						$value .= "(".$field_name[0]->$sel.")";
195
+					} else {
196
+						$value .= $field_name[0]->$sel." ";
197
+					}
198
+				}
199
+			} else {
200
+				$value = "";
201
+			}
202
+		}
203
+		return rtrim($value, ',');
204
+	}
205
+
206
+	function check_did_avl($select, $table, $where) {
207
+		$accountinfo = $this->CI->session->userdata('accountinfo');
208
+		$flag_status = "";
209
+		$where = array("number" => $where);
210
+		$field_name = $this->CI->db_model->getSelect("id,accountid,parent_id", 'dids', $where);
211
+		$field_name = $field_name->result();
212
+		if (isset($field_name) && ! empty($field_name)) {
213
+			if (isset($field_name[0]) && $accountinfo['type'] != 1) {
214
+				if ($field_name[0]->accountid != 0 && $field_name[0]->parent_id == 0) {
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(C)<span></a>";
216
+				} else if ($field_name[0]->parent_id != 0) {
217
+					$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>";
218
+				} else {
219
+					$flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
220
+				}
221
+			} else {
222
+				$reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
223
+				$where = array("note" => $field_name[0]->number, 'parent_id' => $reseller_id);
224
+				$field_name_re = $this->CI->db_model->getSelect("reseller_id", 'reseller_pricing', $where);
225
+				$field_name_re = $field_name_re->result();
226
+
227
+				if (isset($field_name_re) && ! empty($field_name_re)) {
228
+					$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>";
229
+				} else {
230
+					$flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
231
+				}
232
+			}
233
+		} else {
234
+			$flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
235
+		}
236
+		return $flag_status;
237
+	}
238
+	function check_did_avl_export($number) {
239
+	  $this->CI->db->where('number', $number);
240
+	  $this->CI->db->select('id,accountid,parent_id');
241
+	  $status = null;
242
+	  $did_info = (array)$this->CI->db->get('dids')->first_row();
243
+	  $accountinfo = $this->CI->session->userdata('accountinfo');
244
+	  if ($did_info['accountid'] == 0 && $did_info['parent_id'] == 0) {
245 245
 	$status = 'Not in use';
246
-      }
247
-      elseif ($accountinfo['type'] != 1) {
246
+	  }
247
+	  elseif ($accountinfo['type'] != 1) {
248 248
 	if ($did_info['accountid'] == 0 && $did_info['parent_id'] > 0) {
249 249
 	  $status = 'Purchase by Reseller';
250 250
 	}
251 251
 	if ($did_info['accountid'] > 0 && $did_info['parent_id'] == 0) {
252 252
 	  $status = 'Purchase by Customer';
253 253
 	}
254
-      } else {
255
-       $where_arr = array('note'=>$did_info['number'], "parent_id"=>$accountinfo['id']);
256
-       $this->db->where($where);
257
-       $this->CI->db->select('reseller_id,parent_id');
258
-       $reseller_pricing = (array)$this->db->get('reseller_pricing')->first_row();
259
-       if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0 && $did_info['parent_id'] == $accountinfo['id']) {
260
-        $status = 'Not in use';
261
-       }
262
-       if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0) {
263
-       $status = 'Not in use';
264
-       }
265
-      }
266
-      return $status;
254
+	  } else {
255
+	   $where_arr = array('note'=>$did_info['number'], "parent_id"=>$accountinfo['id']);
256
+	   $this->db->where($where);
257
+	   $this->CI->db->select('reseller_id,parent_id');
258
+	   $reseller_pricing = (array)$this->db->get('reseller_pricing')->first_row();
259
+	   if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0 && $did_info['parent_id'] == $accountinfo['id']) {
260
+		$status = 'Not in use';
261
+	   }
262
+	   if ($reseller_pricing['reseller_id'] == 0 && $did_info['accountid'] == 0) {
263
+	   $status = 'Not in use';
264
+	   }
265
+	  }
266
+	  return $status;
267 267
       
268
-    }
269
-    function check_did_avl_reseller($select, $table, $where) {
270
-        $accountinfo = $this->CI->session->userdata('accountinfo');
271
-        $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
272
-        $this->CI->db->where('number', $where);
273
-        $this->CI->db->select('id,accountid,parent_id,number');
274
-        $did_info = (array)$this->CI->db->get('dids')->first_row();
275
-        if ($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']) {
276
-	    $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>";
277
-	}
278
-        else if ($accountinfo['type'] != 1 && $did_info['parent_id'] != $accountinfo['id']) {
279
-	    $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>";
280
-        } else {
281
-	    $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
282
-	    $where = array("note" => $did_info['number'], 'parent_id'=>$reseller_id);
283
-            $this->CI->db->where($where);
284
-	    $this->CI->db->select('reseller_id,id');
285
-	    $reseller_pricing_info = (array)$this->CI->db->get('reseller_pricing')->first_row();
286
-	    if (isset($reseller_pricing_info) && ! empty($reseller_pricing_info)) {
268
+	}
269
+	function check_did_avl_reseller($select, $table, $where) {
270
+		$accountinfo = $this->CI->session->userdata('accountinfo');
271
+		$flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
272
+		$this->CI->db->where('number', $where);
273
+		$this->CI->db->select('id,accountid,parent_id,number');
274
+		$did_info = (array)$this->CI->db->get('dids')->first_row();
275
+		if ($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']) {
276
+		$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>";
277
+	}
278
+		else if ($accountinfo['type'] != 1 && $did_info['parent_id'] != $accountinfo['id']) {
279
+		$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>";
280
+		} else {
281
+		$reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
282
+		$where = array("note" => $did_info['number'], 'parent_id'=>$reseller_id);
283
+			$this->CI->db->where($where);
284
+		$this->CI->db->select('reseller_id,id');
285
+		$reseller_pricing_info = (array)$this->CI->db->get('reseller_pricing')->first_row();
286
+		if (isset($reseller_pricing_info) && ! empty($reseller_pricing_info)) {
287 287
 		  $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>";
288
-	    } else {
289
-	      $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
290
-	    }
291
-        }
292
-        return $flag_status;
293
-    }
288
+		} else {
289
+		  $flag_status = "<span class=' label label-sm label-inverse arrowed-in' title='Not in use'>Not in use</span>";
290
+		}
291
+		}
292
+		return $flag_status;
293
+	}
294 294
 
295 295
 //    get data for Comma seprated
296
-    function get_field_name_coma($select, $table, $where) {
297
-        $value = '';
298
-        if (is_array($where)) {
299
-            $where = $where;
300
-        } else {
301
-            $where = explode(',', $where);
302
-        }
303
-        for ($i = 0; $i < count($where); $i++) {
304
-            $where_in = array("id" => $where[$i]);
305
-
306
-            $field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
307
-            $field_name = $field_name->result();
308
-            if (isset($field_name) && ! empty($field_name)) {
309
-                $value .= $field_name[0]->$select.",";
310
-            } else {
311
-                $value = "";
312
-            }
313
-        }
314
-        return rtrim($value, ',');
315
-    }
316
-
317
-    function set_invoice_option($select = "", $table = "", $call_type = "", $edit_value = '') {
318
-
319
-        $invoice_date = false;
320
-        $uri_segment = $this->CI->uri->segments;
321
-        if (isset($uri_segment[3]) && $uri_segment[3] > 0 && empty($edit_value)) {
322
-            $field_name = $this->CI->db_model->getSelect("sweep_id,invoice_day", "accounts", array("id" => $uri_segment[3]));
323
-            $field_name = $field_name->result_array();
324
-            $select = $field_name[0]["sweep_id"];
325
-            $invoice_date = $field_name[0]["invoice_day"];
326
-        } else {
327
-            $invoice_date = $edit_value;
328
-        }
329
-        if ($select == "" || $select == "0") {
330
-            $daily_arr = array("0" => "0");
331
-            return $daily_arr;
332
-        }
333
-        if ($select == 1) {
334
-            $week_arr = array("1" => "Monday", "2" => "Tuesday", "3" => "Wednesday", "4" => "Thursday", "5" => "Friday",
335
-                "6" => "Saturday", "7" => "Sunday");
336
-            $rawDate = date("Y-m-d");
337
-            $day = date('N', strtotime($rawDate));
338
-            if (isset($uri_segment[3])) {
339
-                return $week_arr;
340
-            } else {
341
-                $week_drp = form_dropdown(array("name" => 'invoice_day', 'style'=>"width: 100% !important;", "class" => "invoice_day"), $week_arr, $day);
342
-                return $week_drp;
343
-            }
344
-        }
345
-        if ($select != 0 && $select != 1) {
346
-            for ($i = 1; $i < 29; $i++) {
347
-                $mon_arr[$i] = $i;
348
-            }
349
-            if (isset($uri_segment[3]) && $uri_segment[3] > 0 && empty($edit_value)) {
350
-                return $mon_arr;
351
-            } else {
352
-                $day = $invoice_date > 0 ? $invoice_date : date('d');
353
-                $month_drp = form_dropdown(array("name" => 'invoice_day', "class" => "width_dropdown invoice_day"), $mon_arr, $day);
354
-                return $month_drp;
355
-            }
356
-        }
357
-    }
358
-
359
-    function set_status($status = '') {
360
-        $status_array = array('0' => 'Active', '1' => 'Inactive',);
361
-        return $status_array;
362
-    }
363
-
364
-    function set_routetype($status = '') {
365
-        $status_array = array('0' => 'LCR', '1' => 'COST',);
366
-        return $status_array;
367
-    }
368
-
369
-    function set_prorate($status = '') {
370
-        $status_array = array('0' => 'Yes', '1' => 'No',);
371
-        return $status_array;
372
-    }
373
-    /*
296
+	function get_field_name_coma($select, $table, $where) {
297
+		$value = '';
298
+		if (is_array($where)) {
299
+			$where = $where;
300
+		} else {
301
+			$where = explode(',', $where);
302
+		}
303
+		for ($i = 0; $i < count($where); $i++) {
304
+			$where_in = array("id" => $where[$i]);
305
+
306
+			$field_name = $this->CI->db_model->getSelect($select, $table, $where_in);
307
+			$field_name = $field_name->result();
308
+			if (isset($field_name) && ! empty($field_name)) {
309
+				$value .= $field_name[0]->$select.",";
310
+			} else {
311
+				$value = "";
312
+			}
313
+		}
314
+		return rtrim($value, ',');
315
+	}
316
+
317
+	function set_invoice_option($select = "", $table = "", $call_type = "", $edit_value = '') {
318
+
319
+		$invoice_date = false;
320
+		$uri_segment = $this->CI->uri->segments;
321
+		if (isset($uri_segment[3]) && $uri_segment[3] > 0 && empty($edit_value)) {
322
+			$field_name = $this->CI->db_model->getSelect("sweep_id,invoice_day", "accounts", array("id" => $uri_segment[3]));
323
+			$field_name = $field_name->result_array();
324
+			$select = $field_name[0]["sweep_id"];
325
+			$invoice_date = $field_name[0]["invoice_day"];
326
+		} else {
327
+			$invoice_date = $edit_value;
328
+		}
329
+		if ($select == "" || $select == "0") {
330
+			$daily_arr = array("0" => "0");
331
+			return $daily_arr;
332
+		}
333
+		if ($select == 1) {
334
+			$week_arr = array("1" => "Monday", "2" => "Tuesday", "3" => "Wednesday", "4" => "Thursday", "5" => "Friday",
335
+				"6" => "Saturday", "7" => "Sunday");
336
+			$rawDate = date("Y-m-d");
337
+			$day = date('N', strtotime($rawDate));
338
+			if (isset($uri_segment[3])) {
339
+				return $week_arr;
340
+			} else {
341
+				$week_drp = form_dropdown(array("name" => 'invoice_day', 'style'=>"width: 100% !important;", "class" => "invoice_day"), $week_arr, $day);
342
+				return $week_drp;
343
+			}
344
+		}
345
+		if ($select != 0 && $select != 1) {
346
+			for ($i = 1; $i < 29; $i++) {
347
+				$mon_arr[$i] = $i;
348
+			}
349
+			if (isset($uri_segment[3]) && $uri_segment[3] > 0 && empty($edit_value)) {
350
+				return $mon_arr;
351
+			} else {
352
+				$day = $invoice_date > 0 ? $invoice_date : date('d');
353
+				$month_drp = form_dropdown(array("name" => 'invoice_day', "class" => "width_dropdown invoice_day"), $mon_arr, $day);
354
+				return $month_drp;
355
+			}
356
+		}
357
+	}
358
+
359
+	function set_status($status = '') {
360
+		$status_array = array('0' => 'Active', '1' => 'Inactive',);
361
+		return $status_array;
362
+	}
363
+
364
+	function set_routetype($status = '') {
365
+		$status_array = array('0' => 'LCR', '1' => 'COST',);
366
+		return $status_array;
367
+	}
368
+
369
+	function set_prorate($status = '') {
370
+		$status_array = array('0' => 'Yes', '1' => 'No',);
371
+		return $status_array;
372
+	}
373
+	/*
374 374
       Add For Package Inbound or Outbound or both?
375 375
     */
376
-    function set_package_type($applicable_for = "") {
377
-        $package_applicable = array('0' => 'Outbound', '1' => 'Inbound', '2' => 'Both');
378
-        return $package_applicable;
379
-    }
380
-
381
-    function get_package_type($status = '', $table = "", $applicable_for) {
382
-        $package_applicable = array('0' => 'Outbound', '1' => 'Inbound', '2' => 'Both');
383
-        return $package_applicable[$applicable_for];
384
-    }
385
-    /******************************************** */
386
-    function set_allow($status = '') {
387
-        $status_array = array('1' => 'Yes', '0' => 'No');
388
-        return $status_array;
389
-    }
390
-    function set_allow_invoice($status = '') {
391
-        $status_array = array('1' => 'Yes', '0' => 'No');
392
-        return $status_array;
393
-    }
394
-    function set_pin_allow($status = '') {
395
-        $status_array = array('0' => 'Disable', '1' => 'Enable');
396
-        return $status_array;
397
-    }
398
-    function set_pin_allow_customer($status = '') {
399
-        $status_array = array('0' => 'No', '1' => 'Yes');
400
-        return $status_array;
401
-    }
402
-    function get_allow($select = "", $table = "", $status) {
403
-        return ($status == 1) ? "Yes" : "No";
404
-    }
405
-
406
-    function set_call_type($call_type = "") {
407
-        $call_type_array = array("-1" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
408
-        return $call_type_array;
409
-    }
410
-    function set_call_type_search() {
376
+	function set_package_type($applicable_for = "") {
377
+		$package_applicable = array('0' => 'Outbound', '1' => 'Inbound', '2' => 'Both');
378
+		return $package_applicable;
379
+	}
380
+
381
+	function get_package_type($status = '', $table = "", $applicable_for) {
382
+		$package_applicable = array('0' => 'Outbound', '1' => 'Inbound', '2' => 'Both');
383
+		return $package_applicable[$applicable_for];
384
+	}
385
+	/******************************************** */
386
+	function set_allow($status = '') {
387
+		$status_array = array('1' => 'Yes', '0' => 'No');
388
+		return $status_array;
389
+	}
390
+	function set_allow_invoice($status = '') {
391
+		$status_array = array('1' => 'Yes', '0' => 'No');
392
+		return $status_array;
393
+	}
394
+	function set_pin_allow($status = '') {
395
+		$status_array = array('0' => 'Disable', '1' => 'Enable');
396
+		return $status_array;
397
+	}
398
+	function set_pin_allow_customer($status = '') {
399
+		$status_array = array('0' => 'No', '1' => 'Yes');
400
+		return $status_array;
401
+	}
402
+	function get_allow($select = "", $table = "", $status) {
403
+		return ($status == 1) ? "Yes" : "No";
404
+	}
405
+
406
+	function set_call_type($call_type = "") {
407
+		$call_type_array = array("-1" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
408
+		return $call_type_array;
409
+	}
410
+	function set_call_type_search() {
411 411
 	$call_type_array = array("" => "--Select--", '1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other',);
412
-        return $call_type_array;
413
-    }
414
-    function get_call_type($select = "", $table = "", $call_type) {
415
-        $call_type_array = array('1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other', '-1'=>"");
416
-        return $call_type_array[$call_type];
417
-    }
418
-
419
-    function get_custom_call_type($call_type) {
420
-        $call_type_array = array('DID-Local' => '1', "SIP-DID"=>"3", 'PSTN' => '0', 'Other' => '2', ""=>"-1");
421
-        return $call_type_array[$call_type];
422
-    }
423
-
424
-    function set_sip_config_option($option = "") {
425
-        $config_option = array("true" => "True", "false" => "False");
426
-        return $config_option;
427
-    }
428
-
429
-    function get_entity_type($select = "", $table = "", $entity_type) {
430
-        $entity_array = array('-1' => "Administrator", '0' => 'Customer', '1' => 'Reseller', '2' => 'Admin', '3' => "Provider", "4" => "Subadmin", "5" => "Callshop");
431
-        return($entity_array[$entity_type]);
432
-    }
433
-
434
-    function set_entity_type_customer($entity_type = "") {
435
-        $entity_array = array('' => "--Select--", '0' => 'Customer', '3' => "Provider");
436
-        return $entity_array;
437
-    }
438
-
439
-    function set_entity_type_admin($entity_type = "") {
440
-        $entity_array = array('' => "--Select--", '2' => 'Admin', "4" => "Sub Admin");
441
-        return $entity_array;
442
-    }
412
+		return $call_type_array;
413
+	}
414
+	function get_call_type($select = "", $table = "", $call_type) {
415
+		$call_type_array = array('1' => 'DID-Local', "3"=>"SIP-DID", '0' => 'PSTN', '2' => 'Other', '-1'=>"");
416
+		return $call_type_array[$call_type];
417
+	}
418
+
419
+	function get_custom_call_type($call_type) {
420
+		$call_type_array = array('DID-Local' => '1', "SIP-DID"=>"3", 'PSTN' => '0', 'Other' => '2', ""=>"-1");
421
+		return $call_type_array[$call_type];
422
+	}
423
+
424
+	function set_sip_config_option($option = "") {
425
+		$config_option = array("true" => "True", "false" => "False");
426
+		return $config_option;
427
+	}
428
+
429
+	function get_entity_type($select = "", $table = "", $entity_type) {
430
+		$entity_array = array('-1' => "Administrator", '0' => 'Customer', '1' => 'Reseller', '2' => 'Admin', '3' => "Provider", "4" => "Subadmin", "5" => "Callshop");
431
+		return($entity_array[$entity_type]);
432
+	}
433
+
434
+	function set_entity_type_customer($entity_type = "") {
435
+		$entity_array = array('' => "--Select--", '0' => 'Customer', '3' => "Provider");
436
+		return $entity_array;
437
+	}
438
+
439
+	function set_entity_type_admin($entity_type = "") {
440
+		$entity_array = array('' => "--Select--", '2' => 'Admin', "4" => "Sub Admin");
441
+		return $entity_array;
442
+	}
443 443
 
444 444
 	function set_entity_type_email_mass($entity_type = "") {
445
-        $entity_array = array('' => "--Select--", '0' => 'Customer', '1'=>'Reseller', '3' => "Provider");
446
-        return $entity_array;
447
-    }
448
-
449
-    function set_sip_config_options($option = "") {
450
-        $config_option = array("false" => "False", "true" => "True");
451
-        return $config_option;
452
-    }
453
-
454
-    function set_sip_config_default($option = "") {
455
-        $config_option = array("" => "--SELECT--", "false" => "False", "true" => "True");
456
-        return $config_option;
457
-    }
458
-
459
-    function set_sip_bind_params($option = "") {
460
-        $config_option = array("" => "--SELECT--", "udp" => "UDP", "tcp" => "TCP");
461
-        return $config_option;
462
-    }
463
-
464
-    function set_sip_vad_option() {
465
-        $config_option = array("in" => "In", "out" => "Out", "both" => "Both");
466
-        return $config_option;
467
-    }
468
-
469
-    function set_sip_drp_option($option = "") {
470
-        $status_array = array('no' => 'No', 'yes' => 'Yes');
471
-        return $status_array;
472
-    }
473
-
474
-    function set_status_callingcard($status = '') {
475
-        $status_array = array('1' => 'Active', '0' => 'Inactive', '2' => 'Deleted');
476
-        return $status_array;
477
-    }
445
+		$entity_array = array('' => "--Select--", '0' => 'Customer', '1'=>'Reseller', '3' => "Provider");
446
+		return $entity_array;
447
+	}
448
+
449
+	function set_sip_config_options($option = "") {
450
+		$config_option = array("false" => "False", "true" => "True");
451
+		return $config_option;
452
+	}
453
+
454
+	function set_sip_config_default($option = "") {
455
+		$config_option = array("" => "--SELECT--", "false" => "False", "true" => "True");
456
+		return $config_option;
457
+	}
458
+
459
+	function set_sip_bind_params($option = "") {
460
+		$config_option = array("" => "--SELECT--", "udp" => "UDP", "tcp" => "TCP");
461
+		return $config_option;
462
+	}
463
+
464
+	function set_sip_vad_option() {
465
+		$config_option = array("in" => "In", "out" => "Out", "both" => "Both");
466
+		return $config_option;
467
+	}
468
+
469
+	function set_sip_drp_option($option = "") {
470
+		$status_array = array('no' => 'No', 'yes' => 'Yes');
471
+		return $status_array;
472
+	}
473
+
474
+	function set_status_callingcard($status = '') {
475
+		$status_array = array('1' => 'Active', '0' => 'Inactive', '2' => 'Deleted');
476
+		return $status_array;
477
+	}
478 478
    /*
479 479
    show status on all grid
480 480
    */
481 481
    function get_status($select = "", $table = "", $status) {
482
-       if ($select != 'export') {
483
-        $status_tab = $this->encode($table);
484
-        $status['table'] = "'".$status_tab."'";
485
-        if ($status['status'] == 0) {
482
+	   if ($select != 'export') {
483
+		$status_tab = $this->encode($table);
484
+		$status['table'] = "'".$status_tab."'";
485
+		if ($status['status'] == 0) {
486 486
 	$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>
487 487
 	<label class="onoffswitch-label" for=switch'.$status["id"].'>
488 488
      	<span class="onoffswitch-inner"></span>
@@ -497,249 +497,249 @@  discard block
 block discarded – undo
497 497
 		return ($status == 0) ? "Active" : "Inactive";
498 498
 	}
499 499
 	return $status_array;
500
-    }
500
+	}
501 501
    
502
-    function get_routetype($select = "", $table = "", $status) {
503
-        return ($status == 0) ? "LCR" : "COST";
504
-    }
502
+	function get_routetype($select = "", $table = "", $status) {
503
+		return ($status == 0) ? "LCR" : "COST";
504
+	}
505 505
    
506 506
    function get_prorate($select = "", $table = "", $status) {
507
-        return ($status == 0) ? "Yes" : "No";
508
-    }
507
+		return ($status == 0) ? "Yes" : "No";
508
+	}
509 509
     
510
-    function get_import_status($status) {
511
-     return strtolower(trim($status)) == 'active' ? 0 : 1;
510
+	function get_import_status($status) {
511
+	 return strtolower(trim($status)) == 'active' ? 0 : 1;
512 512
      
513
-    }
514
-    function get_did_status($select, $table, $status) {
513
+	}
514
+	function get_did_status($select, $table, $status) {
515 515
     
516
-      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>";
517
-    }
516
+	  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>";
517
+	}
518 518
    
519 519
 
520
-    /**
521
-     * @param string $select
522
-     */
523
-    function get_invoice_date($select, $accountid = 0, $reseller_id, $order_by = 'id') {
524
-        $where = array("reseller_id" => $reseller_id);
525
-        if ($accountid > 0) {
526
-            $where['accountid'] = $accountid;
527
-        }
528
-        $invoice_res = $this->CI->db_model->select($select, "invoices", $where, $order_by, "DESC", "1", "0");
529
-        if ($invoice_res->num_rows > 0) {
530
-            $invoice_info = (array)$invoice_res->first_row();
531
-            return $invoice_info[$select];
532
-        }
533
-        return false;
534
-    }
535
-
536
-    function convert_to_date($select = '', $table = '', $from_date) {
537
-
538
-        $from_date = date('Y-m-d', strtotime($from_date));
539
-        return $from_date;
540
-    }
541
-
542
-
543
-    function get_account_balance($select = "", $table = "", $amount) {
544
-        $this->CI->load->model('common_model');
545
-        if ($amount == 0) {
546
-            return $amount;
547
-        } else {
548
-            $balance = $this->CI->common_model->add_calculate_currency(($amount), "", '', true, true);
549
-
550
-            return $balance;
551
-        }
552
-    }
553
-
554
-    function convert_to_currency($select = "", $table = "", $amount) {
555
-        $this->CI->load->model('common_model');
556
-        return $this->CI->common_model->calculate_currency($amount, '', '', true, false);
557
-    }
558
-    function account_number_icon($select = "", $table = "", $number) {
559
-    $return_value = '';
560
-    $where = array('number'=>$number);
561
-    $account_res = (array)$this->CI->db->get_where("accounts", $where)->first_row();
562
-    if ($account_res['type'] == 0) {
563
-    $return_value = '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>".$account_res['number']." </span>";    
564
-    }
565
-    if ($account_res['type'] == 3) {
566
-    $return_value = '<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res['number']." </span>";
567
-    }
568
-    if ($account_res['type'] == -1 || $account_res['type'] == 2) {
569
-      $return_value = '<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res['number']." </span>";
570
-    }
571
-    if ($account_res['type'] == 4) {
572
-      $return_value = '<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res['number']." </span>";
573
-    }
574
-    return $return_value;
575
-    }
576
-    function convert_to_currency_account($select = "", $table = "", $amount) {
577
-        $this->CI->load->model('common_model');
578
-        return $this->CI->common_model->calculate_currency_customer($amount);
579
-    }
580
-
581
-    function get_paid_status($select = "", $table = "", $status) {
582
-        return ($status == 1) ? "Paid" : "Unpaid";
583
-    }
584
-
585
-    function set_account_type($status = '') {
586
-        $status_array = array('0' => 'Prepaid', '1' => 'Postpaid');
587
-        return $status_array;
588
-    }
589
-
590
-    function set_account_type_search($status = '') {
591
-        $status_array = array('' => "--Select--", '0' => 'Prepaid', '1' => 'Postpaid');
592
-        return $status_array;
593
-    }
594
-
595
-    function get_account_type($select = "", $table = "", $PTE) {
596
-        return ($PTE == 1) ? "Postpaid" : "Prepaid";
597
-    }
598
-
599
-    /******
520
+	/**
521
+	 * @param string $select
522
+	 */
523
+	function get_invoice_date($select, $accountid = 0, $reseller_id, $order_by = 'id') {
524
+		$where = array("reseller_id" => $reseller_id);
525
+		if ($accountid > 0) {
526
+			$where['accountid'] = $accountid;
527
+		}
528
+		$invoice_res = $this->CI->db_model->select($select, "invoices", $where, $order_by, "DESC", "1", "0");
529
+		if ($invoice_res->num_rows > 0) {
530
+			$invoice_info = (array)$invoice_res->first_row();
531
+			return $invoice_info[$select];
532
+		}
533
+		return false;
534
+	}
535
+
536
+	function convert_to_date($select = '', $table = '', $from_date) {
537
+
538
+		$from_date = date('Y-m-d', strtotime($from_date));
539
+		return $from_date;
540
+	}
541
+
542
+
543
+	function get_account_balance($select = "", $table = "", $amount) {
544
+		$this->CI->load->model('common_model');
545
+		if ($amount == 0) {
546
+			return $amount;
547
+		} else {
548
+			$balance = $this->CI->common_model->add_calculate_currency(($amount), "", '', true, true);
549
+
550
+			return $balance;
551
+		}
552
+	}
553
+
554
+	function convert_to_currency($select = "", $table = "", $amount) {
555
+		$this->CI->load->model('common_model');
556
+		return $this->CI->common_model->calculate_currency($amount, '', '', true, false);
557
+	}
558
+	function account_number_icon($select = "", $table = "", $number) {
559
+	$return_value = '';
560
+	$where = array('number'=>$number);
561
+	$account_res = (array)$this->CI->db->get_where("accounts", $where)->first_row();
562
+	if ($account_res['type'] == 0) {
563
+	$return_value = '<div class="flx_font flx_magenta" title="Customer">C</div>'." <span title='Edit'>".$account_res['number']." </span>";    
564
+	}
565
+	if ($account_res['type'] == 3) {
566
+	$return_value = '<div class="flx_font flx_blue" title="Provider">P</div>'." <span title='Edit'>".$account_res['number']." </span>";
567
+	}
568
+	if ($account_res['type'] == -1 || $account_res['type'] == 2) {
569
+	  $return_value = '<div class="flx_font flx_pink" title="Admin">A</div>'." <span title='Edit'>".$account_res['number']." </span>";
570
+	}
571
+	if ($account_res['type'] == 4) {
572
+	  $return_value = '<div class="flx_font flx_purple" title="Subadmin">S</div>'." <span title='Edit'>".$account_res['number']." </span>";
573
+	}
574
+	return $return_value;
575
+	}
576
+	function convert_to_currency_account($select = "", $table = "", $amount) {
577
+		$this->CI->load->model('common_model');
578
+		return $this->CI->common_model->calculate_currency_customer($amount);
579
+	}
580
+
581
+	function get_paid_status($select = "", $table = "", $status) {
582
+		return ($status == 1) ? "Paid" : "Unpaid";
583
+	}
584
+
585
+	function set_account_type($status = '') {
586
+		$status_array = array('0' => 'Prepaid', '1' => 'Postpaid');
587
+		return $status_array;
588
+	}
589
+
590
+	function set_account_type_search($status = '') {
591
+		$status_array = array('' => "--Select--", '0' => 'Prepaid', '1' => 'Postpaid');
592
+		return $status_array;
593
+	}
594
+
595
+	function get_account_type($select = "", $table = "", $PTE) {
596
+		return ($PTE == 1) ? "Postpaid" : "Prepaid";
597
+	}
598
+
599
+	/******
600 600
       Payment to refill
601 601
     ******/
602 602
 
603
-    function get_refill_by($select = "", $table = "", $type) {
604
-        if ($type == '-1') {
605
-            $type = "Admin";
606
-        } else {
607
-            $type = $this->get_field_name("number", "accounts", array("id" => $type));
608
-        }
609
-        return $type;
610
-    }
611
-
612
-    /******************* */
613
-
614
-    function get_payment_by($select = "", $table = "", $type) {
615
-        if ($type == '-1') {
616
-            $type = "Admin";
617
-        } else {
618
-            $type = $this->get_field_name("number", "accounts", array("id" => $type));
619
-        }
620
-        return $type;
621
-    }
622
-
623
-    function set_payment_type($payment_type = '') {
624
-        /*
603
+	function get_refill_by($select = "", $table = "", $type) {
604
+		if ($type == '-1') {
605
+			$type = "Admin";
606
+		} else {
607
+			$type = $this->get_field_name("number", "accounts", array("id" => $type));
608
+		}
609
+		return $type;
610
+	}
611
+
612
+	/******************* */
613
+
614
+	function get_payment_by($select = "", $table = "", $type) {
615
+		if ($type == '-1') {
616
+			$type = "Admin";
617
+		} else {
618
+			$type = $this->get_field_name("number", "accounts", array("id" => $type));
619
+		}
620
+		return $type;
621
+	}
622
+
623
+	function set_payment_type($payment_type = '') {
624
+		/*
625 625
          * Recharge to Refill
626 626
          */
627
-        $status_array = array('0' => 'Refill', '1' => 'Postcharge',);
628
-        return $status_array;
629
-    }
630
-
631
-    function search_int_type($status = '') {
632
-        $status_array = array('1' => 'Is Equal To', '2' => 'Is Not Equal To', '3' => 'Greater Than', '4' => 'Less Than', '5' => 'Greater Or Equal Than', '6' => 'Less Or Equal Than');
633
-        return $status_array;
634
-    }
635
-
636
-    function update_int_type($status = '') {
637
-        $status_array = array('1' => 'Preserve', '2' => 'Set To', '3' => 'Increase By', '4' => 'Decrease By');
638
-        return $status_array;
639
-    }
640
-
641
-    function update_drp_type($status = '') {
642
-        $status_array = array('1' => 'Preserve', '2' => 'Set To');
643
-        return $status_array;
644
-    }
645
-
646
-    function search_string_type($status = '') {
647
-        $status_array = array('5'=>"Begins With", '1' => 'Contains', '2' => 'Doesnt Contain', '3' => 'Is Equal To', '4' => 'Is Not Equal To', "6"=>"Ends With");
648
-        return $status_array;
649
-    }
650
-
651
-    function set_protocal($protpcal = '') {
652
-        $status_array = array('SIP' => 'SIP', 'IAX2' => 'IAX2', 'Zap' => 'Zap', 'Local' => 'Local', 'OH323' => 'OH323', 'OOH323C' => 'OOH323C');
653
-        return $status_array;
654
-    }
655
-
656
-    /*
627
+		$status_array = array('0' => 'Refill', '1' => 'Postcharge',);
628
+		return $status_array;
629
+	}
630
+
631
+	function search_int_type($status = '') {
632
+		$status_array = array('1' => 'Is Equal To', '2' => 'Is Not Equal To', '3' => 'Greater Than', '4' => 'Less Than', '5' => 'Greater Or Equal Than', '6' => 'Less Or Equal Than');
633
+		return $status_array;
634
+	}
635
+
636
+	function update_int_type($status = '') {
637
+		$status_array = array('1' => 'Preserve', '2' => 'Set To', '3' => 'Increase By', '4' => 'Decrease By');
638
+		return $status_array;
639
+	}
640
+
641
+	function update_drp_type($status = '') {
642
+		$status_array = array('1' => 'Preserve', '2' => 'Set To');
643
+		return $status_array;
644
+	}
645
+
646
+	function search_string_type($status = '') {
647
+		$status_array = array('5'=>"Begins With", '1' => 'Contains', '2' => 'Doesnt Contain', '3' => 'Is Equal To', '4' => 'Is Not Equal To', "6"=>"Ends With");
648
+		return $status_array;
649
+	}
650
+
651
+	function set_protocal($protpcal = '') {
652
+		$status_array = array('SIP' => 'SIP', 'IAX2' => 'IAX2', 'Zap' => 'Zap', 'Local' => 'Local', 'OH323' => 'OH323', 'OOH323C' => 'OOH323C');
653
+		return $status_array;
654
+	}
655
+
656
+	/*
657 657
      *
658 658
      * Purpose : Add Profit Margin report
659 659
      * Version 2.1
660 660
      */
661 661
 
662
-    function set_notify_by($status = '') {
663
-        $status_array = array('' => 'Select Notify By', '0' => 'CSV', '1' => 'Email');
664
-        return $status_array;
665
-    }
662
+	function set_notify_by($status = '') {
663
+		$status_array = array('' => 'Select Notify By', '0' => 'CSV', '1' => 'Email');
664
+		return $status_array;
665
+	}
666 666
 
667
-    function convert_to_percentage($select = "", $table = "", $amount) {
668
-        return round($amount, 2)." %";
669
-    }
667
+	function convert_to_percentage($select = "", $table = "", $amount) {
668
+		return round($amount, 2)." %";
669
+	}
670 670
 
671
-    function convert_to_minutes($select = "", $table = "", $amount) {
672
-        return str_replace('.', ':', round($amount / 60, 2));
673
-    }
671
+	function convert_to_minutes($select = "", $table = "", $amount) {
672
+		return str_replace('.', ':', round($amount / 60, 2));
673
+	}
674 674
 
675
-    function set_filter_type_search($status = '') {
676
-        $status_array = array('pricelist_id' => 'Rate Group', 'accountid' => 'Customer', 'reseller_id' => 'Reseller');
677
-        return $status_array;
678
-    }
675
+	function set_filter_type_search($status = '') {
676
+		$status_array = array('pricelist_id' => 'Rate Group', 'accountid' => 'Customer', 'reseller_id' => 'Reseller');
677
+		return $status_array;
678
+	}
679 679
     
680
-    	function set_routetype_status($select = '') {
681
-        $status_array = array("" => "--Select--",
682
-            "0" => "LCR",
683
-            "1" => "COST"
684
-        );
685
-        return $status_array;
680
+		function set_routetype_status($select = '') {
681
+		$status_array = array("" => "--Select--",
682
+			"0" => "LCR",
683
+			"1" => "COST"
684
+		);
685
+		return $status_array;
686 686
 }
687 687
 	
688 688
 
689
-    //attachment download in email module...
690
-    function attachment_icons($select = "", $table = "", $attachement = "") {
691
-        if ($attachement != "") {
692
-            $array = explode(",", $attachement);
693
-            $str = '';	
694
-            foreach ($array as $key => $val) {
695
-                $link = base_url()."email/email_history_list_attachment/".$val;
696
-                $str .= "<a href='".$link."' title='".$val."' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a>&nbsp;&nbsp;";
697
-            }
698
-            return $str;
699
-        } else {
700
-            return "";
701
-        }
702
-    }
703
-
704
-    /*     * ************************************************************* */
705
-
706
-    function set_despostion($dis = '') {
707
-        $status_array = array("" => "--Select Disposition--",
708
-            "UNSPECIFIED" => "UNSPECIFIED",
709
-            "UNALLOCATED_NUMBER" => "UNALLOCATED_NUMBER",
710
-            "NO_ROUTE_DESTINATION" => "NO_ROUTE_DESTINATION",
711
-            "CHANNEL_UNACCEPTABLE" => "CHANNEL_UNACCEPTABLE",
712
-            "NORMAL_CLEARING" => "NORMAL_CLEARING",
713
-            "SUCCESS" => "SUCCESS",
714
-            "USER_BUSY" => "USER_BUSY",
715
-            "NO_USER_RESPONSE" => "NO_USER_RESPONSE",
716
-            "NO_ANSWER" => "NO_ANSWER",
717
-            "CALL_REJECTED" => "CALL_REJECTED",
718
-            "NUMBER_CHANGED" => "NUMBER_CHANGED",
719
-            "DESTINATION_OUT_OF_ORDER" => "DESTINATION_OUT_OF_ORDER",
720
-            "INVALID_NUMBER_FORMAT" => "INVALID_NUMBER_FORMAT",
721
-            "FACILITY_REJECTED" => "FACILITY_REJECTED",
722
-            "NORMAL_UNSPECIFIED" => "NORMAL_UNSPECIFIED",
723
-            "NORMAL_CIRCUIT_CONGESTION" => "NORMAL_CIRCUIT_CONGESTION",
724
-            "NETWORK_OUT_OF_ORDER" => "NETWORK_OUT_OF_ORDER",
725
-            "NORMAL_TEMPORARY_FAILURE" => "NORMAL_TEMPORARY_FAILURE",
726
-            "SWITCH_CONGESTION" => "SWITCH_CONGESTION",
727
-            "FACILITY_NOT_SUBSCRIBED" => "FACILITY_NOT_SUBSCRIBED",
728
-            "OUTGOING_CALL_BARRED" => "OUTGOING_CALL_BARRED",
729
-            "BEARERCAPABILITY_NOTAUTH" => "BEARERCAPABILITY_NOTAUTH",
730
-            "BEARERCAPABILITY_NOTAVAIL" => "BEARERCAPABILITY_NOTAVAIL",
731
-            "SERVICE_UNAVAILABLE" => "SERVICE_UNAVAILABLE",
732
-            "BEARERCAPABILITY_NOTIMPL" => "BEARERCAPABILITY_NOTIMPL",
733
-            "CHAN_NOT_IMPLEMENTED" => "CHAN_NOT_IMPLEMENTED",
734
-            "FACILITY_NOT_IMPLEMENTED" => "FACILITY_NOT_IMPLEMENTED",
735
-            "SERVICE_NOT_IMPLEMENTED" => "SERVICE_NOT_IMPLEMENTED",
736
-            "INCOMPATIBLE_DESTINATION" => "INCOMPATIBLE_DESTINATION",
737
-            "RECOVERY_ON_TIMER_EXPIRE" => "RECOVERY_ON_TIMER_EXPIRE",
738
-            "ORIGINATOR_CANCEL" => "ORIGINATOR_CANCEL",
739
-            "ALLOTTED_TIMEOUT" => "ALLOTTED_TIMEOUT",
740
-            "MEDIA_TIMEOUT" => "MEDIA_TIMEOUT",
741
-            "PROGRESS_TIMEOUT" => "PROGRESS_TIMEOUT",
742
-            "AUTHENTICATION_FAIL" => "AUTHENTICATION_FAIL",
689
+	//attachment download in email module...
690
+	function attachment_icons($select = "", $table = "", $attachement = "") {
691
+		if ($attachement != "") {
692
+			$array = explode(",", $attachement);
693
+			$str = '';	
694
+			foreach ($array as $key => $val) {
695
+				$link = base_url()."email/email_history_list_attachment/".$val;
696
+				$str .= "<a href='".$link."' title='".$val."' class='btn btn-royelblue btn-sm'><i class='fa fa-paperclip fa-fw'></i></a>&nbsp;&nbsp;";
697
+			}
698
+			return $str;
699
+		} else {
700
+			return "";
701
+		}
702
+	}
703
+
704
+	/*     * ************************************************************* */
705
+
706
+	function set_despostion($dis = '') {
707
+		$status_array = array("" => "--Select Disposition--",
708
+			"UNSPECIFIED" => "UNSPECIFIED",
709
+			"UNALLOCATED_NUMBER" => "UNALLOCATED_NUMBER",
710
+			"NO_ROUTE_DESTINATION" => "NO_ROUTE_DESTINATION",
711
+			"CHANNEL_UNACCEPTABLE" => "CHANNEL_UNACCEPTABLE",
712
+			"NORMAL_CLEARING" => "NORMAL_CLEARING",
713
+			"SUCCESS" => "SUCCESS",
714
+			"USER_BUSY" => "USER_BUSY",
715
+			"NO_USER_RESPONSE" => "NO_USER_RESPONSE",
716
+			"NO_ANSWER" => "NO_ANSWER",
717
+			"CALL_REJECTED" => "CALL_REJECTED",
718
+			"NUMBER_CHANGED" => "NUMBER_CHANGED",
719
+			"DESTINATION_OUT_OF_ORDER" => "DESTINATION_OUT_OF_ORDER",
720
+			"INVALID_NUMBER_FORMAT" => "INVALID_NUMBER_FORMAT",
721
+			"FACILITY_REJECTED" => "FACILITY_REJECTED",
722
+			"NORMAL_UNSPECIFIED" => "NORMAL_UNSPECIFIED",
723
+			"NORMAL_CIRCUIT_CONGESTION" => "NORMAL_CIRCUIT_CONGESTION",
724
+			"NETWORK_OUT_OF_ORDER" => "NETWORK_OUT_OF_ORDER",
725
+			"NORMAL_TEMPORARY_FAILURE" => "NORMAL_TEMPORARY_FAILURE",
726
+			"SWITCH_CONGESTION" => "SWITCH_CONGESTION",
727
+			"FACILITY_NOT_SUBSCRIBED" => "FACILITY_NOT_SUBSCRIBED",
728
+			"OUTGOING_CALL_BARRED" => "OUTGOING_CALL_BARRED",
729
+			"BEARERCAPABILITY_NOTAUTH" => "BEARERCAPABILITY_NOTAUTH",
730
+			"BEARERCAPABILITY_NOTAVAIL" => "BEARERCAPABILITY_NOTAVAIL",
731
+			"SERVICE_UNAVAILABLE" => "SERVICE_UNAVAILABLE",
732
+			"BEARERCAPABILITY_NOTIMPL" => "BEARERCAPABILITY_NOTIMPL",
733
+			"CHAN_NOT_IMPLEMENTED" => "CHAN_NOT_IMPLEMENTED",
734
+			"FACILITY_NOT_IMPLEMENTED" => "FACILITY_NOT_IMPLEMENTED",
735
+			"SERVICE_NOT_IMPLEMENTED" => "SERVICE_NOT_IMPLEMENTED",
736
+			"INCOMPATIBLE_DESTINATION" => "INCOMPATIBLE_DESTINATION",
737
+			"RECOVERY_ON_TIMER_EXPIRE" => "RECOVERY_ON_TIMER_EXPIRE",
738
+			"ORIGINATOR_CANCEL" => "ORIGINATOR_CANCEL",
739
+			"ALLOTTED_TIMEOUT" => "ALLOTTED_TIMEOUT",
740
+			"MEDIA_TIMEOUT" => "MEDIA_TIMEOUT",
741
+			"PROGRESS_TIMEOUT" => "PROGRESS_TIMEOUT",
742
+			"AUTHENTICATION_FAIL" => "AUTHENTICATION_FAIL",
743 743
 			"ACCOUNT_INACTIVE_DELETED" => "ACCOUNT_INACTIVE_DELETED",
744 744
 			"ACCOUNT_EXPIRE" => "ACCOUNT_EXPIRE",
745 745
 			"NO_SUFFICIENT_FUND" => "NO_SUFFICIENT_FUND",
@@ -1154,780 +1154,780 @@  discard block
 block discarded – undo
1154 1154
 				} else{
1155 1155
 					$accountinfo['did_maxchannels'] = "Unlimited";
1156 1156
 				}
1157
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1158
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'] , $message);
1159
-                $message = str_replace('#COUNTRYNAME#',$accountinfo['did_country_id'], $message);
1160
-                $message = str_replace('#SETUPFEE#',$accountinfo['did_setup'], $message);
1161
-                $message = str_replace('#MONTHLYFEE#',$accountinfo['did_monthlycost'], $message);
1162
-                $message = str_replace('#MAXCHANNEL#',$accountinfo['did_maxchannels'], $message);
1163
-                $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1157
+				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1158
+				$message = str_replace('#DIDNUMBER#', $accountinfo['did_number'] , $message);
1159
+				$message = str_replace('#COUNTRYNAME#',$accountinfo['did_country_id'], $message);
1160
+				$message = str_replace('#SETUPFEE#',$accountinfo['did_setup'], $message);
1161
+				$message = str_replace('#MONTHLYFEE#',$accountinfo['did_monthlycost'], $message);
1162
+				$message = str_replace('#MAXCHANNEL#',$accountinfo['did_maxchannels'], $message);
1163
+				$message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1164 1164
 				$subject = $query[0]->subject;
1165 1165
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
1166 1166
 				$subject = str_replace("#DIDNUMBER#", $accountinfo['did_number'], $subject);
1167
-                break;
1168
-            case 'email_remove_did';
1169
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1170
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'],$message);
1171
-                $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1167
+				break;
1168
+			case 'email_remove_did';
1169
+				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1170
+				$message = str_replace('#DIDNUMBER#', $accountinfo['did_number'],$message);
1171
+				$message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1172 1172
 				$subject = $query[0]->subject;
1173 1173
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
1174 1174
 				$subject = str_replace("#DIDNUMBER#", $accountinfo['did_number'], $subject);
1175
-                break;
1176
-        }
1175
+				break;
1176
+		}
1177 1177
         
1178
-        if ($subject == "") {
1178
+		if ($subject == "") {
1179 1179
 			$subject = $query[0]->subject;
1180 1180
 			$subject = str_replace("#NAME#", $accountinfo['first_name']." ".$accountinfo['last_name'], $subject);
1181 1181
 			$subject = str_replace("#COMPANY_NAME#", $company_name, $subject);	
1182 1182
 		}
1183
-        $account_id = (isset($accountinfo['last_id']) && $accountinfo['last_id'] != "") ? $accountinfo['last_id'] : $accountinfo['id'];
1184
-        $reseller_id = $accountinfo['reseller_id'];
1185
-        if ($reseller_id != "0") {
1186
-            $reseller_result = $this->CI->db_model->getSelect("email", "accounts", array("id" => $reseller_id));
1187
-            $reseller_info = (array)$reseller_result->first_row();
1188
-            $settings_reply_email = $reseller_info['email'];
1189
-        }
1190
-        $this->emailFunction($settings_reply_email, $useremail, $subject, $message, $company_name, $attachment, $account_id, $reseller_id);
1183
+		$account_id = (isset($accountinfo['last_id']) && $accountinfo['last_id'] != "") ? $accountinfo['last_id'] : $accountinfo['id'];
1184
+		$reseller_id = $accountinfo['reseller_id'];
1185
+		if ($reseller_id != "0") {
1186
+			$reseller_result = $this->CI->db_model->getSelect("email", "accounts", array("id" => $reseller_id));
1187
+			$reseller_info = (array)$reseller_result->first_row();
1188
+			$settings_reply_email = $reseller_info['email'];
1189
+		}
1190
+		$this->emailFunction($settings_reply_email, $useremail, $subject, $message, $company_name, $attachment, $account_id, $reseller_id);
1191 1191
 
1192
-    }
1192
+	}
1193 1193
 
1194
-    /**
1195
-     * @param string $message
1196
-     */
1197
-    function emailFunction($from, $to, $subject, $message, $company_name = "", $attachment = "", $account_id, $reseller_id) {
1198
-        $send_mail_details = array('from' => $from,
1199
-            'to' => $to,
1200
-            'subject' => $subject,
1201
-            'body' => $message,
1202
-            'accountid' => $account_id,
1203
-            'status' => '1',
1204
-            'attachment' => $attachment,
1205
-            'reseller_id' => $reseller_id,
1206
-        );
1194
+	/**
1195
+	 * @param string $message
1196
+	 */
1197
+	function emailFunction($from, $to, $subject, $message, $company_name = "", $attachment = "", $account_id, $reseller_id) {
1198
+		$send_mail_details = array('from' => $from,
1199
+			'to' => $to,
1200
+			'subject' => $subject,
1201
+			'body' => $message,
1202
+			'accountid' => $account_id,
1203
+			'status' => '1',
1204
+			'attachment' => $attachment,
1205
+			'reseller_id' => $reseller_id,
1206
+		);
1207 1207
                 
1208
-        $this->CI->db->insert('mail_details', $send_mail_details);
1209
-        return $this->CI->db->insert_id();
1210
-    }
1208
+		$this->CI->db->insert('mail_details', $send_mail_details);
1209
+		return $this->CI->db->insert_id();
1210
+	}
1211 1211
 
1212
-    /*
1212
+	/*
1213 1213
       convert GMT id 0000 condition
1214 1214
      */
1215 1215
 
1216
-    function convert_GMT_to($select = "", $table = "", $date) {
1217
-        if ($date == '0000-00-00 00:00:00') {
1218
-            return $date;
1219
-        } else {
1220
-            return $this->CI->timezone->display_GMT($date);
1221
-        }
1222
-    }
1223
-
1224
-    function convert_GMT($date) {
1225
-        return $this->CI->timezone->convert_to_GMT($select = "", $table = "", $date);
1226
-    }
1227
-
1228
-    function convert_to_ucfirst($select = "", $table = "", $str_value) {
1229
-        return ucfirst($str_value);
1230
-    }
1231
-
1232
-    function set_charge_type($status = '') {
1233
-        $status_array = array('1' => 'Accounts', '2' => 'Rate Group');
1234
-        return $status_array;
1235
-    }
1236
-
1237
-    function build_concat_string($select, $table, $id_where = '') {
1238
-        $select_params = explode(',', $select);
1239
-        $where = array("1");
1240
-        if ($id_where != '') {
1241
-            $where = array("id" => $id_where);
1242
-        }
1243
-        $select_params = explode(',', $select);
1244
-        if (isset($select_params[3])) {
1245
-            $cnt_str = " $select_params[0],' ',$select_params[1],' ','(',$select_params[2],')' ";
1246
-        } else {
1247
-            $cnt_str = " $select_params[0],' (',$select_params[1],')' ";
1248
-        }
1249
-        $select = "concat($cnt_str) as $select_params[0] ";
1250
-        $drp_array = $this->CI->db_model->getSelect($select, $table, $where);
1251
-        $drp_array = $drp_array->result();
1252
-        if (isset($drp_array[0])) {
1253
-                    return $drp_array[0]->$select_params[0];
1254
-        }
1255
-    }
1256
-
1257
-    /* 
1216
+	function convert_GMT_to($select = "", $table = "", $date) {
1217
+		if ($date == '0000-00-00 00:00:00') {
1218
+			return $date;
1219
+		} else {
1220
+			return $this->CI->timezone->display_GMT($date);
1221
+		}
1222
+	}
1223
+
1224
+	function convert_GMT($date) {
1225
+		return $this->CI->timezone->convert_to_GMT($select = "", $table = "", $date);
1226
+	}
1227
+
1228
+	function convert_to_ucfirst($select = "", $table = "", $str_value) {
1229
+		return ucfirst($str_value);
1230
+	}
1231
+
1232
+	function set_charge_type($status = '') {
1233
+		$status_array = array('1' => 'Accounts', '2' => 'Rate Group');
1234
+		return $status_array;
1235
+	}
1236
+
1237
+	function build_concat_string($select, $table, $id_where = '') {
1238
+		$select_params = explode(',', $select);
1239
+		$where = array("1");
1240
+		if ($id_where != '') {
1241
+			$where = array("id" => $id_where);
1242
+		}
1243
+		$select_params = explode(',', $select);
1244
+		if (isset($select_params[3])) {
1245
+			$cnt_str = " $select_params[0],' ',$select_params[1],' ','(',$select_params[2],')' ";
1246
+		} else {
1247
+			$cnt_str = " $select_params[0],' (',$select_params[1],')' ";
1248
+		}
1249
+		$select = "concat($cnt_str) as $select_params[0] ";
1250
+		$drp_array = $this->CI->db_model->getSelect($select, $table, $where);
1251
+		$drp_array = $drp_array->result();
1252
+		if (isset($drp_array[0])) {
1253
+					return $drp_array[0]->$select_params[0];
1254
+		}
1255
+	}
1256
+
1257
+	/* 
1258 1258
      * Change invoice_total to invoice details 
1259 1259
      */
1260 1260
 
1261
-    function get_invoice_total($select = '', $table = '', $id) {
1262
-        $where_arr = array('invoiceid' => $id, 'item_type <>' => "FREE");
1263
-        $this->CI->db->where($where_arr);
1264
-        $this->CI->db->select('*');
1265
-        $result = $this->CI->db->get('invoice_details');
1266
-        if ($result->num_rows() > 0) {
1267
-            $result = $result->result_array();
1268
-	    if ($select == 'debit') {
1261
+	function get_invoice_total($select = '', $table = '', $id) {
1262
+		$where_arr = array('invoiceid' => $id, 'item_type <>' => "FREE");
1263
+		$this->CI->db->where($where_arr);
1264
+		$this->CI->db->select('*');
1265
+		$result = $this->CI->db->get('invoice_details');
1266
+		if ($result->num_rows() > 0) {
1267
+			$result = $result->result_array();
1268
+		if ($select == 'debit') {
1269 1269
 		if ($result[0]['item_type'] == 'POSTCHARG') {
1270
-	            return $this->convert_to_currency('', '', $result[0]['debit']);
1270
+				return $this->convert_to_currency('', '', $result[0]['debit']);
1271 1271
 		} else {
1272
-	            return $this->convert_to_currency('', '', $result[0]['credit']);
1272
+				return $this->convert_to_currency('', '', $result[0]['credit']);
1273 1273
 		}
1274
-	    } else {
1274
+		} else {
1275 1275
 		   return $result[0][$select];
1276
-	    }
1277
-        } else {
1278
-            return null;
1279
-        }
1280
-    }
1281
-
1282
-    function get_array($select, $table_name, $where = false) {
1283
-        $new_array = array();
1284
-        $select_params = array();
1285
-        $select_params = explode(",", $select);
1286
-        if (isset($select_params[3])) {
1287
-            $cnt_str = " $select_params[1],'(',$select_params[2],' ',$select_params[3],')' ";
1288
-            $select = "concat($cnt_str) as $select_params[3] ";
1289
-            $field_name = $select_params[3];
1290
-        } elseif (isset($select_params[2])) {
1291
-            $cnt_str = " $select_params[1],' ','(',$select_params[2],')' ";
1292
-            $select = "concat($cnt_str) as $select_params[2] ";
1293
-            $field_name = $select_params[2];
1294
-        } else {
1295
-            $select = $select_params[1];
1296
-            $field_name = $select_params[1];
1297
-        }
1298
-        if ($where) {
1299
-            $this->CI->db->where($where);
1300
-        }
1301
-        $this->CI->db->select("$select_params[0],$select", false);
1302
-        $result = $this->CI->db->get($table_name);
1303
-        foreach ($result->result_array() as $key => $value) {
1304
-            $new_array[$value[$select_params[0]]] = $value[$field_name];
1305
-        }
1306
-        ksort($new_array);
1307
-        return $new_array;
1308
-    }
1309
-
1310
-    function get_timezone_offset() {
1311
-        $gmtoffset = 0;
1312
-        $accountinfo = $this->CI->session->userdata('accountinfo');
1313
-        $account_result = $this->CI->db->get_where('accounts', array('id' => $accountinfo['id']));
1314
-        $account_result = $account_result->result_array();
1315
-        $accountinfo = $account_result[0];
1316
-        $timezone_id_arr = array($accountinfo['timezone_id']);
1317
-        $this->CI->db->where_in('id', $timezone_id_arr);
1318
-        $this->CI->db->select('gmtoffset');
1319
-        $this->CI->db->from('timezone');
1320
-        $timezone_result = $this->CI->db->get();
1321
-        if ($timezone_result->num_rows() > 0) {
1322
-
1323
-            $timezone_result = $timezone_result->result_array();
1324
-            foreach ($timezone_result as $data) {
1325
-                $gmtoffset += $data['gmtoffset'];
1326
-            }
1327
-        }
1276
+		}
1277
+		} else {
1278
+			return null;
1279
+		}
1280
+	}
1281
+
1282
+	function get_array($select, $table_name, $where = false) {
1283
+		$new_array = array();
1284
+		$select_params = array();
1285
+		$select_params = explode(",", $select);
1286
+		if (isset($select_params[3])) {
1287
+			$cnt_str = " $select_params[1],'(',$select_params[2],' ',$select_params[3],')' ";
1288
+			$select = "concat($cnt_str) as $select_params[3] ";
1289
+			$field_name = $select_params[3];
1290
+		} elseif (isset($select_params[2])) {
1291
+			$cnt_str = " $select_params[1],' ','(',$select_params[2],')' ";
1292
+			$select = "concat($cnt_str) as $select_params[2] ";
1293
+			$field_name = $select_params[2];
1294
+		} else {
1295
+			$select = $select_params[1];
1296
+			$field_name = $select_params[1];
1297
+		}
1298
+		if ($where) {
1299
+			$this->CI->db->where($where);
1300
+		}
1301
+		$this->CI->db->select("$select_params[0],$select", false);
1302
+		$result = $this->CI->db->get($table_name);
1303
+		foreach ($result->result_array() as $key => $value) {
1304
+			$new_array[$value[$select_params[0]]] = $value[$field_name];
1305
+		}
1306
+		ksort($new_array);
1307
+		return $new_array;
1308
+	}
1309
+
1310
+	function get_timezone_offset() {
1311
+		$gmtoffset = 0;
1312
+		$accountinfo = $this->CI->session->userdata('accountinfo');
1313
+		$account_result = $this->CI->db->get_where('accounts', array('id' => $accountinfo['id']));
1314
+		$account_result = $account_result->result_array();
1315
+		$accountinfo = $account_result[0];
1316
+		$timezone_id_arr = array($accountinfo['timezone_id']);
1317
+		$this->CI->db->where_in('id', $timezone_id_arr);
1318
+		$this->CI->db->select('gmtoffset');
1319
+		$this->CI->db->from('timezone');
1320
+		$timezone_result = $this->CI->db->get();
1321
+		if ($timezone_result->num_rows() > 0) {
1322
+
1323
+			$timezone_result = $timezone_result->result_array();
1324
+			foreach ($timezone_result as $data) {
1325
+				$gmtoffset += $data['gmtoffset'];
1326
+			}
1327
+		}
1328 1328
 // 	  echo $gmtoffset;exit;
1329
-        return $gmtoffset;
1330
-    }
1331
-    /** Version 2.1
1332
-     * Purpose : Set default data for new created profile
1333
-     * */
1334
-    function sip_profile_date() {
1335
-        $defualt_profile_data = '{"rtp_ip":"$${local_ip_v4}","dialplan":"XML","user-agent-string":"ASTPP","debug":"0","sip-trace":"no","tls":"false","inbound-reg-force-matching-username":"true","disable-transcoding":"true","all-reg-options-ping":"false","unregister-on-options-fail":"true","log-auth-failures":"true","status":"0","inbound-bypass-media":"false","inbound-proxy-media":"false","disable-transfer":"true","enable-100rel":"false","rtp-timeout-sec":"60","dtmf-duration":"2000","manual-redirect":"false","aggressive-nat-detection":"false","enable-timer":"false","minimum-session-expires":"120","session-timeout-pt":"1800","auth-calls":"true","apply-inbound-acl":"default","inbound-codec-prefs":"PCMU,PCMA,G729","outbound-codec-prefs":"PCMU,PCMA,G729","inbound-late-negotiation":"false"}';
1336
-        return $defualt_profile_data;
1337
-    }
1329
+		return $gmtoffset;
1330
+	}
1331
+	/** Version 2.1
1332
+	 * Purpose : Set default data for new created profile
1333
+	 * */
1334
+	function sip_profile_date() {
1335
+		$defualt_profile_data = '{"rtp_ip":"$${local_ip_v4}","dialplan":"XML","user-agent-string":"ASTPP","debug":"0","sip-trace":"no","tls":"false","inbound-reg-force-matching-username":"true","disable-transcoding":"true","all-reg-options-ping":"false","unregister-on-options-fail":"true","log-auth-failures":"true","status":"0","inbound-bypass-media":"false","inbound-proxy-media":"false","disable-transfer":"true","enable-100rel":"false","rtp-timeout-sec":"60","dtmf-duration":"2000","manual-redirect":"false","aggressive-nat-detection":"false","enable-timer":"false","minimum-session-expires":"120","session-timeout-pt":"1800","auth-calls":"true","apply-inbound-acl":"default","inbound-codec-prefs":"PCMU,PCMA,G729","outbound-codec-prefs":"PCMU,PCMA,G729","inbound-late-negotiation":"false"}';
1336
+		return $defualt_profile_data;
1337
+	}
1338 1338
 
1339
-    /* ===================================================================== */
1340
-    /*
1339
+	/* ===================================================================== */
1340
+	/*
1341 1341
      * Purpose : Add following for mass mail and mail history
1342 1342
      * Version 2.1
1343 1343
      */
1344 1344
 
1345
-    function set_search_temp($select = '') {
1346
-        $status_array = array("0" => "--Select--",
1347
-            "1" => "Voip account refilled",
1348
-            "3" => "Email add user",
1349
-            "4" => "Add sip device",
1350
-            "8" => "Email add did",
1351
-            "9" => "Email remove did",
1352
-            "10" => "Email new invoice",
1353
-            "11" => "Email low balance",
1354
-            "12" => "Email signup confirmation",
1355
-            "13" => "Password successfully changed",
1356
-            "14" => "Reset your password",
1357
-            "15" => "Email add subscription",
1358
-            "16" => "Email remove subscription",
1359
-            "17" => "Email add package",
1360
-            "18" => "Email remove package",
1361
-            "19" => "Voip child accont refilled",
1362
-        );
1363
-        return $status_array;
1364
-    }
1365
-
1366
-    /*     ***
1345
+	function set_search_temp($select = '') {
1346
+		$status_array = array("0" => "--Select--",
1347
+			"1" => "Voip account refilled",
1348
+			"3" => "Email add user",
1349
+			"4" => "Add sip device",
1350
+			"8" => "Email add did",
1351
+			"9" => "Email remove did",
1352
+			"10" => "Email new invoice",
1353
+			"11" => "Email low balance",
1354
+			"12" => "Email signup confirmation",
1355
+			"13" => "Password successfully changed",
1356
+			"14" => "Reset your password",
1357
+			"15" => "Email add subscription",
1358
+			"16" => "Email remove subscription",
1359
+			"17" => "Email add package",
1360
+			"18" => "Email remove package",
1361
+			"19" => "Voip child accont refilled",
1362
+		);
1363
+		return $status_array;
1364
+	}
1365
+
1366
+	/*     ***
1367 1367
       Refill coupon dropdown
1368 1368
      * ** */
1369 1369
 
1370
-    function set_refill_coupon_status($select = '', $table = '', $status = '') {
1371
-        $refill_coupon_array = array("" => "--Select--", '2' => 'Yes', '0' => 'No');
1372
-        return $refill_coupon_array;
1373
-    }
1370
+	function set_refill_coupon_status($select = '', $table = '', $status = '') {
1371
+		$refill_coupon_array = array("" => "--Select--", '2' => 'Yes', '0' => 'No');
1372
+		return $refill_coupon_array;
1373
+	}
1374 1374
 
1375
-    function get_refill_coupon_status($select = '', $table = '', $status) {
1376
-        $refill_coupon_array = array('0' => 'Inactive', '1' => 'Active', '2' => 'Inuse', "3" => "Expired");
1377
-        return $refill_coupon_array[$status];
1378
-    }
1375
+	function get_refill_coupon_status($select = '', $table = '', $status) {
1376
+		$refill_coupon_array = array('0' => 'Inactive', '1' => 'Active', '2' => 'Inuse', "3" => "Expired");
1377
+		return $refill_coupon_array[$status];
1378
+	}
1379 1379
 
1380
-    function firstused_check($select = '', $table = '', $status) {
1380
+	function firstused_check($select = '', $table = '', $status) {
1381 1381
 
1382
-        if ($status == '0000-00-00 00:00:00') {
1383
-            return '-';
1384
-        }
1385
-        return $status;
1386
-    }
1382
+		if ($status == '0000-00-00 00:00:00') {
1383
+			return '-';
1384
+		}
1385
+		return $status;
1386
+	}
1387 1387
 
1388
-    function get_refill_coupon_used($select = '', $table = '', $status) {
1389
-        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">';
1390
-    }
1388
+	function get_refill_coupon_used($select = '', $table = '', $status) {
1389
+		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">';
1390
+	}
1391 1391
 
1392
-    /*     * *******
1392
+	/*     * *******
1393 1393
       Password encode decode
1394 1394
      * ******* */
1395 1395
 
1396
-    /**
1397
-     * @param string $string
1398
-     */
1399
-    function encode_params($string) {
1400
-        $data = base64_encode($string);
1401
-        $data = str_replace(array('+', '/', '='), array('-', '$', ''), $data);
1402
-        return $data;
1403
-    }
1404
-
1405
-    /**
1406
-     * @param string $value
1407
-     */
1408
-    function encode($value) {
1409
-        $text = $value;
1410
-        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
1411
-        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
1412
-        $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->CI->config->item('private_key'), $text, MCRYPT_MODE_ECB, $iv);
1413
-        return trim($this->encode_params($crypttext));
1414
-    }
1415
-
1416
-    function decode_params($string) {
1417
-        $data = str_replace(array('-', '$'), array('+', '/'), $string);
1418
-        $mod4 = strlen($data) % 4;
1419
-        if ($mod4) {
1420
-            $data .= substr('====', $mod4);
1421
-        }
1422
-        return base64_decode($data);
1423
-    }
1424
-
1425
-    function decode($value) {
1426
-        $crypttext = $this->decode_params($value);
1427
-        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
1428
-        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
1429
-        $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->CI->config->item('private_key'), $crypttext, MCRYPT_MODE_ECB, $iv);
1430
-        return trim($decrypttext);
1431
-    }
1432
-
1433
-    /******
1396
+	/**
1397
+	 * @param string $string
1398
+	 */
1399
+	function encode_params($string) {
1400
+		$data = base64_encode($string);
1401
+		$data = str_replace(array('+', '/', '='), array('-', '$', ''), $data);
1402
+		return $data;
1403
+	}
1404
+
1405
+	/**
1406
+	 * @param string $value
1407
+	 */
1408
+	function encode($value) {
1409
+		$text = $value;
1410
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
1411
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
1412
+		$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->CI->config->item('private_key'), $text, MCRYPT_MODE_ECB, $iv);
1413
+		return trim($this->encode_params($crypttext));
1414
+	}
1415
+
1416
+	function decode_params($string) {
1417
+		$data = str_replace(array('-', '$'), array('+', '/'), $string);
1418
+		$mod4 = strlen($data) % 4;
1419
+		if ($mod4) {
1420
+			$data .= substr('====', $mod4);
1421
+		}
1422
+		return base64_decode($data);
1423
+	}
1424
+
1425
+	function decode($value) {
1426
+		$crypttext = $this->decode_params($value);
1427
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
1428
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
1429
+		$decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->CI->config->item('private_key'), $crypttext, MCRYPT_MODE_ECB, $iv);
1430
+		return trim($decrypttext);
1431
+	}
1432
+
1433
+	/******
1434 1434
       Recording enable/disable dropdown
1435 1435
      * ** */
1436 1436
 
1437
-    function set_recording($status = '') {
1438
-        $status_array = array('0' => 'On', '1' => 'Off',);
1439
-        return $status_array;
1440
-    }
1437
+	function set_recording($status = '') {
1438
+		$status_array = array('0' => 'On', '1' => 'Off',);
1439
+		return $status_array;
1440
+	}
1441 1441
 
1442
-    /*     * ************************** */
1442
+	/*     * ************************** */
1443 1443
 
1444
-    function email_status($select = "", $table = "", $status) {
1445
-        $status = ($status['status'] == 0) ? "Sent" : "Not Sent";
1444
+	function email_status($select = "", $table = "", $status) {
1445
+		$status = ($status['status'] == 0) ? "Sent" : "Not Sent";
1446 1446
 	return $status;    
1447
-    }
1447
+	}
1448 1448
 
1449
-    function email_search_status($select = '') {
1450
-        $status_array = array("" => "--Select--",
1451
-            "0" => "Sent",
1452
-            "1" => "Not Sent"
1453
-        );
1454
-        return $status_array;
1455
-    }
1449
+	function email_search_status($select = '') {
1450
+		$status_array = array("" => "--Select--",
1451
+			"0" => "Sent",
1452
+			"1" => "Not Sent"
1453
+		);
1454
+		return $status_array;
1455
+	}
1456 1456
 
1457
-    /* ===================================================================== */
1457
+	/* ===================================================================== */
1458 1458
 
1459 1459
 
1460
-    /*
1460
+	/*
1461 1461
      * Purpose : Add following for setting page
1462 1462
      * Version 2.1
1463 1463
      */
1464 1464
 
1465
-    function paypal_status($status = '') {
1466
-        $status_array = array('0' => 'Enable', '1' => 'Disable');
1467
-        return $status_array;
1468
-    }
1469
-    function playback_audio_notification($status = '') {
1470
-        $status_array = array('0' => 'Enable', '1' => 'Disable');
1471
-        return $status_array;
1472
-    }
1473
-    function custom_status($status) {
1465
+	function paypal_status($status = '') {
1466
+		$status_array = array('0' => 'Enable', '1' => 'Disable');
1467
+		return $status_array;
1468
+	}
1469
+	function playback_audio_notification($status = '') {
1470
+		$status_array = array('0' => 'Enable', '1' => 'Disable');
1471
+		return $status_array;
1472
+	}
1473
+	function custom_status($status) {
1474 1474
 		$status_array = array('0' => 'Yes', '1' => 'No');
1475
-        return $status_array;
1476
-    }
1475
+		return $status_array;
1476
+	}
1477 1477
     
1478
-    function custom_status_active($status) {
1479
-      $status_array = array('0' => 'Active', '1' => 'InActive');
1480
-      return $status_array;
1481
-    }
1482
-    function custom_status_true($status) {
1483
-      $status_array = array('0' => 'TRUE', '1' => 'FALSE');
1484
-      return $status_array;
1485
-    }
1486
-    function custom_status_voicemail($status) {
1487
-      $status_array = array('true' => 'True', 'false' => 'False');
1488
-      return $status_array;
1489
-    }
1490
-
1491
-    /******
1478
+	function custom_status_active($status) {
1479
+	  $status_array = array('0' => 'Active', '1' => 'InActive');
1480
+	  return $status_array;
1481
+	}
1482
+	function custom_status_true($status) {
1483
+	  $status_array = array('0' => 'TRUE', '1' => 'FALSE');
1484
+	  return $status_array;
1485
+	}
1486
+	function custom_status_voicemail($status) {
1487
+	  $status_array = array('true' => 'True', 'false' => 'False');
1488
+	  return $status_array;
1489
+	}
1490
+
1491
+	/******
1492 1492
       For enable Signup module
1493 1493
      * */
1494
-    function create_sipdevice($status = '') {
1495
-        $status_array = array('0' => 'Enable', '1' => 'Disable');
1496
-        return $status_array;
1497
-    }
1494
+	function create_sipdevice($status = '') {
1495
+		$status_array = array('0' => 'Enable', '1' => 'Disable');
1496
+		return $status_array;
1497
+	}
1498 1498
 
1499
-    function enable_signup($status = '') {
1500
-        $status_array = array('0' => 'Enable', '1' => 'Disable');
1501
-        return $status_array;
1502
-    }
1499
+	function enable_signup($status = '') {
1500
+		$status_array = array('0' => 'Enable', '1' => 'Disable');
1501
+		return $status_array;
1502
+	}
1503 1503
 
1504 1504
 	function balance_announce($status = '') {
1505
-        $status_array = array('0' => 'Enable', '1' => 'Disable');
1506
-        return $status_array;
1507
-    }
1505
+		$status_array = array('0' => 'Enable', '1' => 'Disable');
1506
+		return $status_array;
1507
+	}
1508 1508
 	function minutes_announce($status = '') {
1509
-        $status_array = array('0' => 'Enable', '1' => 'Disable');
1510
-        return $status_array;
1511
-    }
1509
+		$status_array = array('0' => 'Enable', '1' => 'Disable');
1510
+		return $status_array;
1511
+	}
1512 1512
 	
1513
-    function enable_disable_option() {
1514
-        $option_array = array('0' => 'Enable', '1' => 'Disable');
1515
-        return $option_array;
1516
-    }
1517
-
1518
-    function paypal_mode($status = '') {
1519
-        $status_array = array('0' => 'Live', '1' => 'Sandbox',);
1520
-        return $status_array;
1521
-    }
1522
-
1523
-    function paypal_fee($status = '') {
1524
-        $status_array = array('0' => 'Paid By Admin', '1' => 'Paid By Customer',);
1525
-        return $status_array;
1526
-    }
1527
-
1528
-    function email() {
1529
-        $status_array = array('1' => 'Enable', '0' => 'Disable',);
1530
-        return $status_array;
1531
-    }
1532
-
1533
-    function smtp() {
1534
-        return $this->set_allow();
1535
-    }
1536
-
1537
-    function debug() {
1538
-        $status_array = array('1' => 'Enable', '0' => 'Disable',);
1539
-        return $status_array;
1540
-    }
1541
-    function default_signup_rategroup() {
1542
-        $this->CI->db->select("id,name");
1543
-        $this->CI->db->where("status", 0);
1544
-        $this->CI->db->where("reseller_id", 0);
1545
-        $pricelist_result = $this->CI->db->get("pricelists")->result_array();
1546
-        $pricelist_arr = array();
1547
-        foreach ($pricelist_result as $result) {
1548
-            $pricelist_arr[$result['id']] = $result['name'];
1549
-        }
1550
-        return $pricelist_arr;
1513
+	function enable_disable_option() {
1514
+		$option_array = array('0' => 'Enable', '1' => 'Disable');
1515
+		return $option_array;
1516
+	}
1517
+
1518
+	function paypal_mode($status = '') {
1519
+		$status_array = array('0' => 'Live', '1' => 'Sandbox',);
1520
+		return $status_array;
1521
+	}
1522
+
1523
+	function paypal_fee($status = '') {
1524
+		$status_array = array('0' => 'Paid By Admin', '1' => 'Paid By Customer',);
1525
+		return $status_array;
1526
+	}
1527
+
1528
+	function email() {
1529
+		$status_array = array('1' => 'Enable', '0' => 'Disable',);
1530
+		return $status_array;
1531
+	}
1532
+
1533
+	function smtp() {
1534
+		return $this->set_allow();
1535
+	}
1536
+
1537
+	function debug() {
1538
+		$status_array = array('1' => 'Enable', '0' => 'Disable',);
1539
+		return $status_array;
1540
+	}
1541
+	function default_signup_rategroup() {
1542
+		$this->CI->db->select("id,name");
1543
+		$this->CI->db->where("status", 0);
1544
+		$this->CI->db->where("reseller_id", 0);
1545
+		$pricelist_result = $this->CI->db->get("pricelists")->result_array();
1546
+		$pricelist_arr = array();
1547
+		foreach ($pricelist_result as $result) {
1548
+			$pricelist_arr[$result['id']] = $result['name'];
1549
+		}
1550
+		return $pricelist_arr;
1551 1551
         
1552
-    }
1553
-    /******
1552
+	}
1553
+	/******
1554 1554
       Enable Fax feature
1555 1555
      * */
1556
-    function outbound_fax() {
1557
-        $status_array = array('0' => 'Enable', '1' => 'Disable',);
1558
-        return $status_array;
1559
-    }
1560
-
1561
-    function inbound_fax() {
1562
-        $status_array = array('0' => 'Enable', '1' => 'Disable',);
1563
-        return $status_array;
1564
-    }
1565
-
1566
-
1567
-    function opensips() {
1568
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1569
-        return $status_array;
1570
-    }
1571
-
1572
-    function cc_ani_auth() {
1573
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1574
-        return $status_array;
1575
-    }
1576
-
1577
-    function calling_cards_balance_announce() {
1578
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1579
-        return $status_array;
1580
-    }
1581
-
1582
-    function calling_cards_timelimit_announce() {
1583
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1584
-        return $status_array;
1585
-    }
1586
-
1587
-    function calling_cards_rate_announce() {
1588
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1589
-        return $status_array;
1590
-    }
1591
-
1592
-    function startingdigit() {
1593
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1594
-        return $status_array;
1595
-    }
1596
-
1597
-    function SMPT() {
1598
-        $status_array = array('1' => 'Enable', '0' => 'Disable');
1599
-        return $status_array;
1600
-    }
1601
-
1602
-    function country() {
1603
-        return $this->CI->common_model->get_country_list();
1604
-    }
1605
-
1606
-    function default_timezone() {
1607
-        return $this->CI->db_model->build_dropdown('id,gmtzone', 'timezone');
1608
-    }
1609
-
1610
-    function timezone() {
1611
-        return $this->CI->db_model->build_dropdown('gmttime,gmttime', 'timezone');
1612
-    }
1613
-
1614
-    function base_currency() {
1615
-        return $this->CI->db_model->build_dropdown('currency,currencyname', 'currency');
1616
-    }
1617
-
1618
-    /******	
1556
+	function outbound_fax() {
1557
+		$status_array = array('0' => 'Enable', '1' => 'Disable',);
1558
+		return $status_array;
1559
+	}
1560
+
1561
+	function inbound_fax() {
1562
+		$status_array = array('0' => 'Enable', '1' => 'Disable',);
1563
+		return $status_array;
1564
+	}
1565
+
1566
+
1567
+	function opensips() {
1568
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1569
+		return $status_array;
1570
+	}
1571
+
1572
+	function cc_ani_auth() {
1573
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1574
+		return $status_array;
1575
+	}
1576
+
1577
+	function calling_cards_balance_announce() {
1578
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1579
+		return $status_array;
1580
+	}
1581
+
1582
+	function calling_cards_timelimit_announce() {
1583
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1584
+		return $status_array;
1585
+	}
1586
+
1587
+	function calling_cards_rate_announce() {
1588
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1589
+		return $status_array;
1590
+	}
1591
+
1592
+	function startingdigit() {
1593
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1594
+		return $status_array;
1595
+	}
1596
+
1597
+	function SMPT() {
1598
+		$status_array = array('1' => 'Enable', '0' => 'Disable');
1599
+		return $status_array;
1600
+	}
1601
+
1602
+	function country() {
1603
+		return $this->CI->common_model->get_country_list();
1604
+	}
1605
+
1606
+	function default_timezone() {
1607
+		return $this->CI->db_model->build_dropdown('id,gmtzone', 'timezone');
1608
+	}
1609
+
1610
+	function timezone() {
1611
+		return $this->CI->db_model->build_dropdown('gmttime,gmttime', 'timezone');
1612
+	}
1613
+
1614
+	function base_currency() {
1615
+		return $this->CI->db_model->build_dropdown('currency,currencyname', 'currency');
1616
+	}
1617
+
1618
+	/******	
1619 1619
       Calculate Currency manually.
1620 1620
      */
1621 1621
 
1622
-    function calculate_currency_manually($currency_info, $amount, $show_currency_flag = true, $number_format = true) {
1623
-        $decimal_points = $currency_info['decimalpoints'];
1624
-        $system_currency_rate = $currency_info['base_currency']['currencyrate'];
1625
-        $user_currency_rate = $currency_info['user_currency']['currencyrate'];
1626
-        $calculated_amount = (float)(($amount * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']); 
1627
-        if ($number_format) {
1628
-         $calculated_amount = number_format($calculated_amount, $currency_info['decimalpoints']);
1629
-        }
1630
-        if ($show_currency_flag) {
1631
-          return $calculated_amount." ".$currency_info['user_currency']['currency'];
1632
-        } else {
1633
-          return $calculated_amount;
1634
-        }
1635
-    }
1636
-
1637
-    /*
1622
+	function calculate_currency_manually($currency_info, $amount, $show_currency_flag = true, $number_format = true) {
1623
+		$decimal_points = $currency_info['decimalpoints'];
1624
+		$system_currency_rate = $currency_info['base_currency']['currencyrate'];
1625
+		$user_currency_rate = $currency_info['user_currency']['currencyrate'];
1626
+		$calculated_amount = (float)(($amount * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']); 
1627
+		if ($number_format) {
1628
+		 $calculated_amount = number_format($calculated_amount, $currency_info['decimalpoints']);
1629
+		}
1630
+		if ($show_currency_flag) {
1631
+		  return $calculated_amount." ".$currency_info['user_currency']['currency'];
1632
+		} else {
1633
+		  return $calculated_amount;
1634
+		}
1635
+	}
1636
+
1637
+	/*
1638 1638
       Using By Summary Report search
1639 1639
      */
1640 1640
 
1641
-    function search_report_in($select = '') {
1642
-        $status_array = array("minutes" => "Minutes", "seconds" => "Seconds");
1643
-        return $status_array;
1644
-    }
1645
-
1646
-    function set_summarycustomer_groupby($status = '') {
1647
-        $status_array = array('' => "--Select--", 'accountid' => 'Account', 'pattern' => 'Code', 'package_id'=>"Package");
1648
-        return $status_array;
1649
-    }
1650
-
1651
-    function set_summaryprovider_groupby($status = '') {
1652
-        $status_array = array('' => "--Select--", 'provider_id' => 'Account', 'trunk_id' => "Trunks", 'pattern' => 'Code');
1653
-        return $status_array;
1654
-    }
1655
-
1656
-    function get_currency_info() {
1657
-        //System Currency info 
1658
-        $base_currency = Common_model::$global_config['system_config']['base_currency'];
1659
-        //Get Account Information from session to get currency_id
1660
-        $accountinfo = $this->CI->session->userdata('accountinfo');
1661
-        //Get User Currency id 
1662
-        $user_currency_id = $accountinfo['currency_id'] > 0 ? $accountinfo['currency_id'] : $base_currency;
1663
-        $where = "currency = '".$base_currency."' OR id= ".$user_currency_id;
1664
-        $this->CI->db->where($where);
1665
-        $this->CI->db->select('*');
1666
-        $currency_result = $this->CI->db->get('currency');
1667
-
1668
-        if ($currency_result->num_rows() == 2) {
1669
-            $currency_result = $currency_result->result_array();
1670
-            foreach ($currency_result as $key => $records) {
1671
-                //User Currency is currency details of logged in user.
1672
-                if ($records['id'] == $user_currency_id) {
1673
-                    $currency_info['user_currency'] = $records;
1674
-                }
1675
-                //System Currency is currency details of system.
1676
-                if ($records['currency'] == Common_model::$global_config['system_config']['base_currency']) {
1677
-                    $currency_info['base_currency'] = $records;
1678
-                }
1679
-            }
1680
-        } else if ($currency_result->num_rows() == 1) {
1681
-            $currency_info['user_currency'] = $currency_info['base_currency'] = (array)$currency_result->first_row();
1682
-        }
1683
-        //Get Decimal points as per defined from system.
1684
-        $currency_info['decimalpoints'] = Common_model::$global_config['system_config']['decimalpoints'];
1685
-        return $currency_info;
1686
-    }
1687
-
1688
-    function convert_to_show_in($search_name = "", $table = "", $second) {
1689
-        $search_arr = $this->CI->session->userdata($search_name);
1690
-        $show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
1691
-        return ($show_seconds === 'minutes') ? ($second > 0) ?
1692
-                        sprintf('%02d', $second / 60).":".sprintf('%02d', ($second % 60)) : "00:00" : sprintf('%02d', $second);
1693
-    }
1694
-
1695
-    function array_column($input, $columnKey, $indexKey = null) {
1696
-        $array = array();
1697
-        foreach ($input as $value) {
1698
-            if ( ! isset($value[$columnKey])) {
1699
-                trigger_error("Key \"$columnKey\" does not exist in array");
1700
-                return false;
1701
-            }
1702
-
1703
-            if (is_null($indexKey)) {
1704
-                $array[] = $value[$columnKey];
1705
-            } else {
1706
-                if ( ! isset($value[$indexKey])) {
1707
-                    trigger_error("Key \"$indexKey\" does not exist in array");
1708
-                    return false;
1709
-                }
1710
-                if ( ! is_scalar($value[$indexKey])) {
1711
-                    trigger_error("Key \"$indexKey\" does not contain scalar value");
1712
-                    return false;
1713
-                }
1714
-                $array[$value[$indexKey]] = $value[$columnKey];
1715
-            }
1716
-        }
1717
-
1718
-        return $array;
1719
-    }
1720
-
1721
-    function group_by_time() {
1722
-        $status_array = array('' => "--Select--", 'HOUR' => 'Hour', 'DAY' => "Day", 'MONTH' => 'Month', "YEAR" => "Year");
1723
-        return $status_array;
1724
-    }
1725
-
1726
-    function currency_decimal($amount) {
1641
+	function search_report_in($select = '') {
1642
+		$status_array = array("minutes" => "Minutes", "seconds" => "Seconds");
1643
+		return $status_array;
1644
+	}
1645
+
1646
+	function set_summarycustomer_groupby($status = '') {
1647
+		$status_array = array('' => "--Select--", 'accountid' => 'Account', 'pattern' => 'Code', 'package_id'=>"Package");
1648
+		return $status_array;
1649
+	}
1650
+
1651
+	function set_summaryprovider_groupby($status = '') {
1652
+		$status_array = array('' => "--Select--", 'provider_id' => 'Account', 'trunk_id' => "Trunks", 'pattern' => 'Code');
1653
+		return $status_array;
1654
+	}
1655
+
1656
+	function get_currency_info() {
1657
+		//System Currency info 
1658
+		$base_currency = Common_model::$global_config['system_config']['base_currency'];
1659
+		//Get Account Information from session to get currency_id
1660
+		$accountinfo = $this->CI->session->userdata('accountinfo');
1661
+		//Get User Currency id 
1662
+		$user_currency_id = $accountinfo['currency_id'] > 0 ? $accountinfo['currency_id'] : $base_currency;
1663
+		$where = "currency = '".$base_currency."' OR id= ".$user_currency_id;
1664
+		$this->CI->db->where($where);
1665
+		$this->CI->db->select('*');
1666
+		$currency_result = $this->CI->db->get('currency');
1667
+
1668
+		if ($currency_result->num_rows() == 2) {
1669
+			$currency_result = $currency_result->result_array();
1670
+			foreach ($currency_result as $key => $records) {
1671
+				//User Currency is currency details of logged in user.
1672
+				if ($records['id'] == $user_currency_id) {
1673
+					$currency_info['user_currency'] = $records;
1674
+				}
1675
+				//System Currency is currency details of system.
1676
+				if ($records['currency'] == Common_model::$global_config['system_config']['base_currency']) {
1677
+					$currency_info['base_currency'] = $records;
1678
+				}
1679
+			}
1680
+		} else if ($currency_result->num_rows() == 1) {
1681
+			$currency_info['user_currency'] = $currency_info['base_currency'] = (array)$currency_result->first_row();
1682
+		}
1683
+		//Get Decimal points as per defined from system.
1684
+		$currency_info['decimalpoints'] = Common_model::$global_config['system_config']['decimalpoints'];
1685
+		return $currency_info;
1686
+	}
1687
+
1688
+	function convert_to_show_in($search_name = "", $table = "", $second) {
1689
+		$search_arr = $this->CI->session->userdata($search_name);
1690
+		$show_seconds = ( ! empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes';
1691
+		return ($show_seconds === 'minutes') ? ($second > 0) ?
1692
+						sprintf('%02d', $second / 60).":".sprintf('%02d', ($second % 60)) : "00:00" : sprintf('%02d', $second);
1693
+	}
1694
+
1695
+	function array_column($input, $columnKey, $indexKey = null) {
1696
+		$array = array();
1697
+		foreach ($input as $value) {
1698
+			if ( ! isset($value[$columnKey])) {
1699
+				trigger_error("Key \"$columnKey\" does not exist in array");
1700
+				return false;
1701
+			}
1702
+
1703
+			if (is_null($indexKey)) {
1704
+				$array[] = $value[$columnKey];
1705
+			} else {
1706
+				if ( ! isset($value[$indexKey])) {
1707
+					trigger_error("Key \"$indexKey\" does not exist in array");
1708
+					return false;
1709
+				}
1710
+				if ( ! is_scalar($value[$indexKey])) {
1711
+					trigger_error("Key \"$indexKey\" does not contain scalar value");
1712
+					return false;
1713
+				}
1714
+				$array[$value[$indexKey]] = $value[$columnKey];
1715
+			}
1716
+		}
1717
+
1718
+		return $array;
1719
+	}
1720
+
1721
+	function group_by_time() {
1722
+		$status_array = array('' => "--Select--", 'HOUR' => 'Hour', 'DAY' => "Day", 'MONTH' => 'Month', "YEAR" => "Year");
1723
+		return $status_array;
1724
+	}
1725
+
1726
+	function currency_decimal($amount) {
1727 1727
 		$amount = str_replace(',', '', $amount);
1728
-        $decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1729
-        $number_convert = number_format((float)$amount, $decimal_amount, '.', '');
1730
-        return $number_convert;
1731
-    }
1732
-
1733
-    function add_invoice_details($account_arr, $charge_type, $amount, $description) {
1734
-        $accountinfo = $this->CI->session->userdata('accountinfo');
1735
-        $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
1736
-        $where = "accountid IN ('".$reseller_id."','1')";
1737
-        $this->CI->db->where($where);
1738
-        $this->CI->db->select('*');
1739
-        $this->CI->db->order_by('accountid', 'desc');
1740
-        $this->CI->db->limit(1);
1741
-        $invoiceconf = $this->CI->db->get('invoice_conf');
1742
-        $invoice_conf = (array)$invoiceconf->first_row();
1743
-        $last_invoiceid = $this->get_invoice_date('invoiceid', '', $account_arr['reseller_id']);
1744
-        if ($last_invoiceid && $last_invoiceid > 0) {
1745
-            $last_invoiceid = ($last_invoiceid + 1);
1746
-        } else {
1747
-            $last_invoiceid = $invoice_conf['invoice_start_from'];
1748
-        }
1749
-        $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
1750
-        $invoice_prefix = $invoice_conf['invoice_prefix'];
1751
-        $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
1752
-        $invoiceid = $account_arr['posttoexternal'] == 0 ? $this->CI->common_model->generate_receipt($account_arr['id'], $amount, $account_arr, $last_invoiceid, $invoice_prefix, $due_date) : 0;
1728
+		$decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1729
+		$number_convert = number_format((float)$amount, $decimal_amount, '.', '');
1730
+		return $number_convert;
1731
+	}
1732
+
1733
+	function add_invoice_details($account_arr, $charge_type, $amount, $description) {
1734
+		$accountinfo = $this->CI->session->userdata('accountinfo');
1735
+		$reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
1736
+		$where = "accountid IN ('".$reseller_id."','1')";
1737
+		$this->CI->db->where($where);
1738
+		$this->CI->db->select('*');
1739
+		$this->CI->db->order_by('accountid', 'desc');
1740
+		$this->CI->db->limit(1);
1741
+		$invoiceconf = $this->CI->db->get('invoice_conf');
1742
+		$invoice_conf = (array)$invoiceconf->first_row();
1743
+		$last_invoiceid = $this->get_invoice_date('invoiceid', '', $account_arr['reseller_id']);
1744
+		if ($last_invoiceid && $last_invoiceid > 0) {
1745
+			$last_invoiceid = ($last_invoiceid + 1);
1746
+		} else {
1747
+			$last_invoiceid = $invoice_conf['invoice_start_from'];
1748
+		}
1749
+		$last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
1750
+		$invoice_prefix = $invoice_conf['invoice_prefix'];
1751
+		$due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
1752
+		$invoiceid = $account_arr['posttoexternal'] == 0 ? $this->CI->common_model->generate_receipt($account_arr['id'], $amount, $account_arr, $last_invoiceid, $invoice_prefix, $due_date) : 0;
1753 1753
         
1754
-        $insert_arr = array("accountid" => $account_arr['id'],
1755
-            "description" => $description,
1756
-            "debit" => $amount,
1757
-            "credit" => '0',
1758
-            "created_date" => gmdate("Y-m-d H:i:s"),
1759
-            "invoiceid" => $invoiceid,
1760
-            "reseller_id" => $account_arr['reseller_id'],
1761
-            "item_type" => $charge_type,
1762
-            "item_id" => '0',
1763
-        );
1764
-        $this->CI->db->insert("invoice_details", $insert_arr);
1765
-        return true;
1766
-    }
1767
-    /* ASTPP  3.0  Remove all information related to going to delete customer.
1754
+		$insert_arr = array("accountid" => $account_arr['id'],
1755
+			"description" => $description,
1756
+			"debit" => $amount,
1757
+			"credit" => '0',
1758
+			"created_date" => gmdate("Y-m-d H:i:s"),
1759
+			"invoiceid" => $invoiceid,
1760
+			"reseller_id" => $account_arr['reseller_id'],
1761
+			"item_type" => $charge_type,
1762
+			"item_id" => '0',
1763
+		);
1764
+		$this->CI->db->insert("invoice_details", $insert_arr);
1765
+		return true;
1766
+	}
1767
+	/* ASTPP  3.0  Remove all information related to going to delete customer.
1768 1768
      */
1769
-    function customer_delete_dependencies($id){
1770
-          $this->delete_data('ani_map',array('accountid'=>$id));
1771
-          $this->delete_data('block_patterns',array('accountid'=>$id));
1772
-          $this->delete_data('charge_to_account',array('accountid'=>$id));
1773
-          $this->delete_data('counters',array('accountid'=>$id));
1774
-          $this->delete_data('ip_map',array('accountid'=>$id));
1775
-          $this->delete_data('sip_devices',array('accountid'=>$id));
1776
-          $this->delete_data('speed_dial',array('accountid'=>$id));
1777
-          $this->delete_data('taxes_to_accounts',array('accountid'=>$id));
1778
-          $this->delete_data('mail_details',array('accountid'=>$id));
1779
-          $this->update_data('dids',array("accountid"=>$id),array('accountid'=>0));
1780
-          $this->update_data("accounts",array("id"=>$id),array("deleted"=>1));
1781
-    }
1782
-    /*
1769
+	function customer_delete_dependencies($id){
1770
+		  $this->delete_data('ani_map',array('accountid'=>$id));
1771
+		  $this->delete_data('block_patterns',array('accountid'=>$id));
1772
+		  $this->delete_data('charge_to_account',array('accountid'=>$id));
1773
+		  $this->delete_data('counters',array('accountid'=>$id));
1774
+		  $this->delete_data('ip_map',array('accountid'=>$id));
1775
+		  $this->delete_data('sip_devices',array('accountid'=>$id));
1776
+		  $this->delete_data('speed_dial',array('accountid'=>$id));
1777
+		  $this->delete_data('taxes_to_accounts',array('accountid'=>$id));
1778
+		  $this->delete_data('mail_details',array('accountid'=>$id));
1779
+		  $this->update_data('dids',array("accountid"=>$id),array('accountid'=>0));
1780
+		  $this->update_data("accounts",array("id"=>$id),array("deleted"=>1));
1781
+	}
1782
+	/*
1783 1783
      *  ASTPP  3.0 
1784 1784
      *  Remove all information related to going to delete reseller.
1785 1785
      */
1786
-    function reseller_delete_dependencies($id){
1787
-        $accountinfo=$this->CI->session->userdata('accountinfo');
1788
-        $child_arr=$this->select_data("accounts",array("reseller_id"=>$id,"type"=>0),'id,reseller_id');
1789
-        if($child_arr){
1790
-            foreach($child_arr as $value){
1791
-                $this->customer_delete_dependencies($value['id']);
1792
-            }
1793
-        }
1794
-        $package_arr=$this->select_data("packages",array("reseller_id"=>$id),'id');
1795
-        if($package_arr){
1796
-            foreach($package_arr as $value){
1797
-                $this->delete_data('package_patterns',array("id"=>$value['id']));
1798
-            }
1799
-        }
1800
-        $acc_arr=$this->select_data('accounts',array("id"=>$id),'id,reseller_id');
1801
-        $parent_id=0;
1802
-        if($acc_arr){
1803
-            $parent_id=$acc_arr[0]['reseller_id'];
1804
-        }
1805
-        $pricelist_arr=$this->select_data('pricelists',array('reseller_id'=>$id),'id');
1806
-        if($pricelist_arr){
1807
-             foreach($pricelist_arr as $value){
1808
-                $this->delete_data("routing",array("pricelist_id"=>$value['id']));
1809
-                $this->delete_data("routes",array("pricelist_id"=>$value['id']));
1810
-                $this->update_data('pricelists',array('id'=>$value['id']),array('status'=>2));         
1811
-             }
1812
-        }
1813
-        $charge_arr=$this->select_data('charges',array('reseller_id'=>$id),'id');
1814
-        if($charge_arr){
1815
-             foreach($charge_arr as $value){
1816
-                $this->delete_data("charge_to_account",array("charge_id"=>$value['id']));
1817
-             }
1818
-        }
1819
-        $this->delete_data('charges',array('reseller_id'=>$id));
1820
-        $this->update_data('dids',array('parent_id'=>$id),array("parent_id"=>$parent_id));
1821
-        $this->delete_data('reseller_pricing',array("reseller_id"=>$id));
1822
-        $this->delete_data('refill_coupon',array("reseller_id"=>$id));
1823
-        $this->delete_data('mail_details',array('accountid'=>$id));
1824
-        $taxes_arr=$this->select_data('taxes',array("reseller_id"=>$id),'id');
1825
-        if($taxes_arr){
1826
-             foreach($taxes_arr as $value){
1827
-                $this->delete_data("taxes_to_accounts",array("taxes_id"=>$value['id']));
1828
-             }
1829
-        }
1830
-        $this->delete_data('taxes',array("reseller_id"=>$id));
1831
-        $this->delete_data('default_templates',array("reseller_id"=>$id));
1832
-        $package_arr=$this->select_data('packages',array('reseller_id'=>$id),'id');
1833
-        if($package_arr){
1834
-            $this->delete_data("counters",array("package_id"=>$value['id']));
1835
-            $this->delete_data("package_patterns",array("package_id"=>$value['id']));
1836
-        }
1837
-        $this->delete_data('invoice_conf',array('accountid'=>$id));
1838
-        $this->delete_data('packages',array("reseller_id"=>$id));
1839
-        $this->update_data('accounts',array("id"=>$id),array("deleted"=>1));
1840
-    }
1841
-    function subreseller_list($parent_id = '') {
1842
-        $customer_id = $parent_id;
1843
-        $this->reseller_delete_dependencies($parent_id);
1844
-        $query = 'select id,type from accounts where reseller_id = ' . $parent_id .' AND deleted =0';
1845
-        $result = $this->CI->db->query($query);
1846
-        if ($result->num_rows() > 0) {
1847
-            $result = $result->result_array();
1848
-            foreach ($result as $data) {
1849
-	      if($data['type']==1){
1786
+	function reseller_delete_dependencies($id){
1787
+		$accountinfo=$this->CI->session->userdata('accountinfo');
1788
+		$child_arr=$this->select_data("accounts",array("reseller_id"=>$id,"type"=>0),'id,reseller_id');
1789
+		if($child_arr){
1790
+			foreach($child_arr as $value){
1791
+				$this->customer_delete_dependencies($value['id']);
1792
+			}
1793
+		}
1794
+		$package_arr=$this->select_data("packages",array("reseller_id"=>$id),'id');
1795
+		if($package_arr){
1796
+			foreach($package_arr as $value){
1797
+				$this->delete_data('package_patterns',array("id"=>$value['id']));
1798
+			}
1799
+		}
1800
+		$acc_arr=$this->select_data('accounts',array("id"=>$id),'id,reseller_id');
1801
+		$parent_id=0;
1802
+		if($acc_arr){
1803
+			$parent_id=$acc_arr[0]['reseller_id'];
1804
+		}
1805
+		$pricelist_arr=$this->select_data('pricelists',array('reseller_id'=>$id),'id');
1806
+		if($pricelist_arr){
1807
+			 foreach($pricelist_arr as $value){
1808
+				$this->delete_data("routing",array("pricelist_id"=>$value['id']));
1809
+				$this->delete_data("routes",array("pricelist_id"=>$value['id']));
1810
+				$this->update_data('pricelists',array('id'=>$value['id']),array('status'=>2));         
1811
+			 }
1812
+		}
1813
+		$charge_arr=$this->select_data('charges',array('reseller_id'=>$id),'id');
1814
+		if($charge_arr){
1815
+			 foreach($charge_arr as $value){
1816
+				$this->delete_data("charge_to_account",array("charge_id"=>$value['id']));
1817
+			 }
1818
+		}
1819
+		$this->delete_data('charges',array('reseller_id'=>$id));
1820
+		$this->update_data('dids',array('parent_id'=>$id),array("parent_id"=>$parent_id));
1821
+		$this->delete_data('reseller_pricing',array("reseller_id"=>$id));
1822
+		$this->delete_data('refill_coupon',array("reseller_id"=>$id));
1823
+		$this->delete_data('mail_details',array('accountid'=>$id));
1824
+		$taxes_arr=$this->select_data('taxes',array("reseller_id"=>$id),'id');
1825
+		if($taxes_arr){
1826
+			 foreach($taxes_arr as $value){
1827
+				$this->delete_data("taxes_to_accounts",array("taxes_id"=>$value['id']));
1828
+			 }
1829
+		}
1830
+		$this->delete_data('taxes',array("reseller_id"=>$id));
1831
+		$this->delete_data('default_templates',array("reseller_id"=>$id));
1832
+		$package_arr=$this->select_data('packages',array('reseller_id'=>$id),'id');
1833
+		if($package_arr){
1834
+			$this->delete_data("counters",array("package_id"=>$value['id']));
1835
+			$this->delete_data("package_patterns",array("package_id"=>$value['id']));
1836
+		}
1837
+		$this->delete_data('invoice_conf',array('accountid'=>$id));
1838
+		$this->delete_data('packages',array("reseller_id"=>$id));
1839
+		$this->update_data('accounts',array("id"=>$id),array("deleted"=>1));
1840
+	}
1841
+	function subreseller_list($parent_id = '') {
1842
+		$customer_id = $parent_id;
1843
+		$this->reseller_delete_dependencies($parent_id);
1844
+		$query = 'select id,type from accounts where reseller_id = ' . $parent_id .' AND deleted =0';
1845
+		$result = $this->CI->db->query($query);
1846
+		if ($result->num_rows() > 0) {
1847
+			$result = $result->result_array();
1848
+			foreach ($result as $data) {
1849
+		  if($data['type']==1){
1850 1850
 		  $this->reseller_delete_dependencies($data['id']);
1851 1851
 		  $this->subreseller_list($data['id']);
1852
-	      } else{
1852
+		  } else{
1853 1853
 		  $this->customer_delete_dependencies($data['id']);
1854
-	      }
1855
-            }
1856
-        }
1857
-    }
1854
+		  }
1855
+			}
1856
+		}
1857
+	}
1858 1858
     
1859
-    /**
1860
-     * @param string $table_name
1861
-     */
1862
-    function delete_data($table_name,$where_arr){
1863
-        $this->CI->db->where($where_arr);
1864
-        $this->CI->db->delete($table_name);
1865
-    }
1859
+	/**
1860
+	 * @param string $table_name
1861
+	 */
1862
+	function delete_data($table_name,$where_arr){
1863
+		$this->CI->db->where($where_arr);
1864
+		$this->CI->db->delete($table_name);
1865
+	}
1866 1866
 
1867
-    /**
1868
-     * @param string $table_name
1869
-     */
1870
-    function update_data($table_name,$where_arr,$update_arr){
1871
-        $this->CI->db->where($where_arr);
1872
-        $this->CI->db->update($table_name,$update_arr);
1873
-    }
1874
-
1875
-    /**
1876
-     * @param string $table_name
1877
-     * @param string $select
1878
-     */
1879
-    function select_data($table_name,$where_arr,$select){
1880
-        $this->CI->db->where($where_arr);
1881
-        $this->CI->db->select($select);
1882
-        $result=$this->CI->db->get($table_name);
1883
-        if($result->num_rows() > 0){
1884
-            return $result->result_array();
1885
-        } else{
1886
-            return false;
1887
-        }
1888
-    }
1867
+	/**
1868
+	 * @param string $table_name
1869
+	 */
1870
+	function update_data($table_name,$where_arr,$update_arr){
1871
+		$this->CI->db->where($where_arr);
1872
+		$this->CI->db->update($table_name,$update_arr);
1873
+	}
1874
+
1875
+	/**
1876
+	 * @param string $table_name
1877
+	 * @param string $select
1878
+	 */
1879
+	function select_data($table_name,$where_arr,$select){
1880
+		$this->CI->db->where($where_arr);
1881
+		$this->CI->db->select($select);
1882
+		$result=$this->CI->db->get($table_name);
1883
+		if($result->num_rows() > 0){
1884
+			return $result->result_array();
1885
+		} else{
1886
+			return false;
1887
+		}
1888
+	}
1889 1889
     
1890
-    function set_call_waiting($status = '') {
1890
+	function set_call_waiting($status = '') {
1891 1891
 		$status_array = array('0' => 'Enable', '1' => 'Disable');
1892 1892
 		return $status_array;
1893 1893
 	} 
1894
-    function get_call_waiting($select = "", $table = "", $status) {
1895
-        return ($status == 0) ? "Enable" : "Disable";
1894
+	function get_call_waiting($select = "", $table = "", $status) {
1895
+		return ($status == 0) ? "Enable" : "Disable";
1896 1896
 	}
1897 1897
   function set_invoice_details($select= ''){
1898
-        $status_array = array("invoice_select" => "--Select--",
1899
-            "invoice_inactive" => "Deleted Invoices",
1900
-            "invoice_active" => "All Invoices",
1901
-        );
1902
-        return $status_array;
1898
+		$status_array = array("invoice_select" => "--Select--",
1899
+			"invoice_inactive" => "Deleted Invoices",
1900
+			"invoice_active" => "All Invoices",
1901
+		);
1902
+		return $status_array;
1903 1903
 }
1904 1904
 function get_invoice_template($invoicedata,$accountdata,$flag){
1905
-      $login_info = $this->CI->session->userdata('accountinfo');
1906
-
1907
-      $invoice_config = $this->CI->db_model->getSelect("*", "invoice_conf", array('accountid'=>$login_info['id']));
1908
-      $invoice_config= $invoice_config->result_array();
1909
-      $invoice_config_res= $invoice_config[0];
1910
-
1911
-      $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $accountdata["currency_id"]);
1912
-      $accountdata["country"] = $this->get_field_name('country', 'countrycode', $accountdata["country_id"]);
1913
-      $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
1914
-      if($login_info['type'] == -1){
1915
-          $currency = $data["to_currency"];
1916
-      } elseif($login_info['type'] == 1){
1905
+	  $login_info = $this->CI->session->userdata('accountinfo');
1906
+
1907
+	  $invoice_config = $this->CI->db_model->getSelect("*", "invoice_conf", array('accountid'=>$login_info['id']));
1908
+	  $invoice_config= $invoice_config->result_array();
1909
+	  $invoice_config_res= $invoice_config[0];
1910
+
1911
+	  $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $accountdata["currency_id"]);
1912
+	  $accountdata["country"] = $this->get_field_name('country', 'countrycode', $accountdata["country_id"]);
1913
+	  $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
1914
+	  if($login_info['type'] == -1){
1915
+		  $currency = $data["to_currency"];
1916
+	  } elseif($login_info['type'] == 1){
1917 1917
 	  $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $login_info["currency_id"]);
1918
-          $currency = $accountdata["currency_id"];
1919
-      } else{
1920
-          $currency = $accountdata["currency_id"];
1921
-      }
1922
-      $decimal_amount=Common_model::$global_config['system_config']['decimalpoints'];
1923
-      ob_start();
1924
-      $this->CI->load->library('/html2pdf/html2pdf');
1925
-      $this->CI->html2pdf = new HTML2PDF('P','A4','en');
1926
-      $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
1927
-      $template_config=$this->CI->config->item('invoice_template');
1928
-      include($template_config.'invoice_template.php');
1929
-      $content = ob_get_clean();
1930
-      ob_clean();
1918
+		  $currency = $accountdata["currency_id"];
1919
+	  } else{
1920
+		  $currency = $accountdata["currency_id"];
1921
+	  }
1922
+	  $decimal_amount=Common_model::$global_config['system_config']['decimalpoints'];
1923
+	  ob_start();
1924
+	  $this->CI->load->library('/html2pdf/html2pdf');
1925
+	  $this->CI->html2pdf = new HTML2PDF('P','A4','en');
1926
+	  $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
1927
+	  $template_config=$this->CI->config->item('invoice_template');
1928
+	  include($template_config.'invoice_template.php');
1929
+	  $content = ob_get_clean();
1930
+	  ob_clean();
1931 1931
 
1932 1932
 	$ACCOUNTADD = '';
1933 1933
 	$ACCOUNTADD_CUSTOMER ='';
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 
781 781
 	function get_action_buttons($buttons_arr, $linkid) {
782 782
 		$ret_url = '';
783
-		if (!empty($buttons_arr) && $buttons_arr != '') {
783
+		if ( ! empty($buttons_arr) && $buttons_arr != '') {
784 784
 			foreach ($buttons_arr as $button_key => $buttons_params) {
785 785
 				if (strtoupper($button_key) == "EDIT") {
786 786
 					$ret_url .= $this->build_edit_button($buttons_params, $linkid);
@@ -849,31 +849,31 @@  discard block
 block discarded – undo
849 849
 	}
850 850
 
851 851
 	function build_delete_button_animap($url, $linkid) {
852
-		$link = base_url() . $url . "" . $linkid;
853
-		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>';
852
+		$link = base_url().$url."".$linkid;
853
+		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>';
854 854
 	}
855 855
 
856 856
 	function build_edit_button_animap($button_params, $linkid) {
857
-		$link = base_url() . $button_params->url . "" . $linkid;
858
-		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;';
857
+		$link = base_url().$button_params->url."".$linkid;
858
+		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;';
859 859
 	}
860 860
 
861 861
 	function build_animap_button($button_params, $linkid) {
862
-		$link = base_url() . $button_params->url . "" . $linkid;
863
-		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;';
862
+		$link = base_url().$button_params->url."".$linkid;
863
+		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;';
864 864
 	}
865 865
 
866 866
 	function build_edit_button($button_params, $linkid) {
867
-		$link = base_url() . $button_params->url . "" . $linkid;
867
+		$link = base_url().$button_params->url."".$linkid;
868 868
        
869 869
 		if ($button_params->mode == 'popup') {
870
-			$rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
871
-			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;';
870
+			$rel = (isset($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox";
871
+			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;';
872 872
             
873
-		}else if(strpos($link,'customer_edit') !== false){
874
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
875
-		}else {
876
-			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
873
+		} else if (strpos($link, 'customer_edit') !== false) {
874
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
875
+		} else {
876
+			return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
877 877
 		}
878 878
 	}
879 879
 
@@ -881,18 +881,18 @@  discard block
 block discarded – undo
881 881
       For Edit on Account number or name
882 882
 	 **/
883 883
 	function build_custome_edit_button($button_params, $field, $linkid) {
884
-		$link = base_url() . $button_params->url . "" . $linkid;
885
-		if(isset($button_params->layout)){
884
+		$link = base_url().$button_params->url."".$linkid;
885
+		if (isset($button_params->layout)) {
886 886
 			if ($button_params->mode == 'popup') {
887
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">' . $field . '</a>&nbsp;';
887
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox_medium" title="Update">'.$field.'</a>&nbsp;';
888 888
 			} else {
889
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a>&nbsp;';
889
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a>&nbsp;';
890 890
 			}
891
-		} else{ 
891
+		} else { 
892 892
 			if ($button_params->mode == 'popup') {
893
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">' . $field . '</a>&nbsp;';
893
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" rel="facebox" title="Update">'.$field.'</a>&nbsp;';
894 894
 			} else {
895
-				return '<a href="' . $link . '" style="cursor:pointer;color:#005298;" title="Edit">' . $field . '</a>&nbsp;';
895
+				return '<a href="'.$link.'" style="cursor:pointer;color:#005298;" title="Edit">'.$field.'</a>&nbsp;';
896 896
 			}
897 897
 		}
898 898
 	}
@@ -900,126 +900,126 @@  discard block
 block discarded – undo
900 900
 	/************************************ */
901 901
 
902 902
 	function build_edit_button_restore($button_params, $linkid) {
903
-		$link = base_url() . $button_params->url . "" . $linkid;
903
+		$link = base_url().$button_params->url."".$linkid;
904 904
 		if ($button_params->mode == 'popup') {
905
-			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;';
905
+			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;';
906 906
 		} else {
907
-			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;';
907
+			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;';
908 908
 		}
909 909
 	}
910 910
 
911 911
 	function build_delete_button($url, $linkid) {
912
-		$flag='0';
913
-		$data=  explode("/",$url);
914
-		$link = base_url() . $url . "" . $linkid;
915
-		foreach($data as $key=>$value){
916
-			if($value == 'price_delete')
912
+		$flag = '0';
913
+		$data = explode("/", $url);
914
+		$link = base_url().$url."".$linkid;
915
+		foreach ($data as $key=>$value) {
916
+			if ($value == 'price_delete')
917 917
 				$flag = '1';
918
-			if($value == 'trunk_remove')
919
-				$flag='2';
920
-			if($value == 'customer_delete' ||$value =='provider_delete')
921
-				$flag='3';
922
-			if($value == 'reseller_delete')
923
-				$flag='4';
918
+			if ($value == 'trunk_remove')
919
+				$flag = '2';
920
+			if ($value == 'customer_delete' || $value == 'provider_delete')
921
+				$flag = '3';
922
+			if ($value == 'reseller_delete')
923
+				$flag = '4';
924 924
 			}    
925
-			if($flag=='1'){
926
-				$where=array('pricelist_id'=>$linkid,'deleted !=' =>'1');
927
-				$customer_cnt=$this->get_field_count('id','accounts',$where);
928
-					$where=array('pricelist_id'=>$linkid);
929
-					$rategroup_cnt=$this->get_field_count('id','routes',$where);
930
-					if($rategroup_cnt > 0 || $customer_cnt > 0 ){
925
+			if ($flag == '1') {
926
+				$where = array('pricelist_id'=>$linkid, 'deleted !=' =>'1');
927
+				$customer_cnt = $this->get_field_count('id', 'accounts', $where);
928
+					$where = array('pricelist_id'=>$linkid);
929
+					$rategroup_cnt = $this->get_field_count('id', 'routes', $where);
930
+					if ($rategroup_cnt > 0 || $customer_cnt > 0) {
931 931
                         
932
-						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>';
932
+						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>';
933 933
 					}
934
-					else{
935
-						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>';
934
+					else {
935
+						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>';
936 936
 					}
937 937
 			}
938
-			if($flag=='2'){
939
-				$where=array('trunk_id'=>$linkid);
940
-				$trunk_cnt=$this->get_field_count('id','outbound_routes',$where);
941
-				if($trunk_cnt > 0){
942
-					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>';
938
+			if ($flag == '2') {
939
+				$where = array('trunk_id'=>$linkid);
940
+				$trunk_cnt = $this->get_field_count('id', 'outbound_routes', $where);
941
+				if ($trunk_cnt > 0) {
942
+					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>';
943 943
 				}
944
-				else{
945
-					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>';
944
+				else {
945
+					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>';
946 946
 				}
947 947
 			}
948
-			if($flag == '3'){
949
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);">
948
+			if ($flag == '3') {
949
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',3);">
950 950
 		<i class="fa fa-trash fa-fw"></i></a>';
951 951
 			}
952
-			if($flag == '4'){
953
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);">
952
+			if ($flag == '4') {
953
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Delete" onClick="return get_alert_message(0,null,'.$linkid.',4);">
954 954
 		<i class="fa fa-trash fa-fw"></i></a>';
955 955
 			}
956
-			if($flag=='0' && $url.$linkid !='accounts/admin_delete/1' ){
957
-				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>';
956
+			if ($flag == '0' && $url.$linkid != 'accounts/admin_delete/1') {
957
+				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>';
958 958
 			}  
959 959
 	}
960 960
 
961 961
 	function build_view_button($button_params, $linkid) {
962
-		$link = base_url() . $button_params->url . "" . $linkid;
962
+		$link = base_url().$button_params->url."".$linkid;
963 963
 		if ($button_params->mode == 'popup') {
964
-			$rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
965
-			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;';
964
+			$rel = (isset($button_params->layout) && $button_params->layout != '') ? "facebox_".$button_params->layout : "facebox";
965
+			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;';
966 966
 		} else {
967
-			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
967
+			return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="View Details"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
968 968
 		}
969 969
 	}
970 970
 
971 971
 	function build_add_taxes_button($button_params, $linkid) {
972
-		$link = base_url() . $button_params->url . "" . $linkid;
972
+		$link = base_url().$button_params->url."".$linkid;
973 973
 		if ($button_params->mode == 'popup') {
974
-			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;';
974
+			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;';
975 975
 		} else {
976
-			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
976
+			return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Add Account Taxes"><i class="fa fa-reorder fa-fw"></i></a>&nbsp;';
977 977
 		}
978 978
 	}
979 979
 
980 980
 	function build_add_download_database_button($url, $linkid) {
981
-		$link = base_url() . $url . "" . $linkid;
982
-		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;';
981
+		$link = base_url().$url."".$linkid;
982
+		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;';
983 983
 	}
984 984
 
985 985
 	function build_add_callerid_button($button_params, $linkid) {
986
-		$link = base_url() . $button_params->url . "" . $linkid;
986
+		$link = base_url().$button_params->url."".$linkid;
987 987
 		if ($button_params->mode == 'popup') {
988
-			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;';
988
+			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;';
989 989
 		} else {
990
-			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
990
+			return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="CallerID"><i class="fa fa-mobile-phone fa-fw"></i></a>&nbsp;';
991 991
 		}
992 992
 	}
993 993
 
994 994
 	function build_start_button($url, $linkid) {
995
-		$link = base_url() . $url . "" . $linkid;
995
+		$link = base_url().$url."".$linkid;
996 996
 
997
-		return '<a href="' . $link . '" class=""  title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a>&nbsp;';
997
+		return '<a href="'.$link.'" class=""  title="Start" style="text-decoration:none;color: #428BCA;"><b>Start |</b></a>&nbsp;';
998 998
 	}
999 999
 
1000 1000
 	function build_stop_button($url, $linkid) {
1001
-		$link = base_url() . $url . "" . $linkid;
1002
-		return '<a href="' . $link . '" class=""  title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a>&nbsp;';
1001
+		$link = base_url().$url."".$linkid;
1002
+		return '<a href="'.$link.'" class=""  title="Stop" style="text-decoration:none;color: #428BCA;" ><b>Stop |</b></a>&nbsp;';
1003 1003
 	}
1004 1004
 
1005 1005
 	function build_reload_button($url, $linkid) {
1006
-		$link = base_url() . $url . "" . $linkid;
1007
-		return '<a href="' . $link . '" class=""  title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a>&nbsp;';
1006
+		$link = base_url().$url."".$linkid;
1007
+		return '<a href="'.$link.'" class=""  title="reload" style="text-decoration:none;color: #428BCA;"><b>Reload |</b></a>&nbsp;';
1008 1008
 	}
1009 1009
 
1010 1010
 	function build_rescan_button($url, $linkid) {
1011
-		$link = base_url() . $url . "" . $linkid;
1012
-		return '<a href="' . $link . '" class=""  title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a>&nbsp;';
1011
+		$link = base_url().$url."".$linkid;
1012
+		return '<a href="'.$link.'" class=""  title="rescan" style="text-decoration:none;color: #428BCA;"><b>Rescan</b></a>&nbsp;';
1013 1013
 	}
1014 1014
 
1015 1015
 	function build_add_payment_button($url, $linkid) {
1016
-		$link = base_url() . $url . "" . $linkid;
1017
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a>&nbsp;';
1016
+		$link = base_url().$url."".$linkid;
1017
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Refill" ><i class="fa fa-usd fa-fw"></i></a>&nbsp;';
1018 1018
 	}
1019 1019
 
1020 1020
 	function build_add_download_button($url, $linkid) {
1021
-		$link = base_url() . $url . "" . $linkid;
1022
-		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp;';
1021
+		$link = base_url().$url."".$linkid;
1022
+		return '<a href="'.$link.'" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp;';
1023 1023
 	}
1024 1024
 
1025 1025
 	/*
@@ -1028,11 +1028,11 @@  discard block
 block discarded – undo
1028 1028
      */
1029 1029
 
1030 1030
 	function build_edit_button_resend($button_params, $linkid) {
1031
-		$link = base_url() . $button_params->url . "" . $linkid;
1031
+		$link = base_url().$button_params->url."".$linkid;
1032 1032
 		if ($button_params->mode == 'popup') {
1033
-			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1033
+			return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" rel="facebox" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1034 1034
 		} else {
1035
-			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1035
+			return '<a href="'.$link.'" class="btn btn-royelblue btn-sm" title="Resend Mail"><i class="fa fa-repeat"></i></a>&nbsp;';
1036 1036
 		}
1037 1037
 	}
1038 1038
 
@@ -1047,17 +1047,17 @@  discard block
 block discarded – undo
1047 1047
 	function mail_to_users($type, $accountinfo, $attachment = "", $amount = "") {
1048 1048
 		$subject = "";
1049 1049
 		$settings_reply_email = '[email protected]';
1050
-		$reseller_id=$accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0;
1051
-		$where="accountid IN ('".$reseller_id."','1')";
1050
+		$reseller_id = $accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0;
1051
+		$where = "accountid IN ('".$reseller_id."','1')";
1052 1052
 		$this->CI->db->where($where);
1053 1053
 		$this->CI->db->select('emailaddress');
1054 1054
 		$this->CI->db->order_by('accountid', 'desc');
1055 1055
 		$this->CI->db->limit(1);
1056 1056
 		$invoiceconf = $this->CI->db->get('invoice_conf');
1057 1057
 		$invoiceconf = (array)$invoiceconf->first_row();
1058
-		$settings_reply_email=$invoiceconf['emailaddress'];
1059
-		$company_name=Common_model::$global_config['system_config']['company_name'];
1060
-		$company_website=Common_model::$global_config['system_config']['company_website'];
1058
+		$settings_reply_email = $invoiceconf['emailaddress'];
1059
+		$company_name = Common_model::$global_config['system_config']['company_name'];
1060
+		$company_website = Common_model::$global_config['system_config']['company_website'];
1061 1061
 		$where = array('name' => $type);
1062 1062
 		$query = $this->CI->db_model->getSelect("*", "default_templates", $where);
1063 1063
 		$query = $query->result();
@@ -1068,106 +1068,106 @@  discard block
 block discarded – undo
1068 1068
 		$message = str_replace("#COMPANY_NAME#", $company_name, $message);
1069 1069
 		$message = str_replace("#COMPANY_WEBSITE#", $company_website, $message);
1070 1070
 		$message = str_replace("</p>", "", $message);
1071
-		if(isset($accountinfo['refill_amount']) && $accountinfo['refill_amount']!= ""){
1071
+		if (isset($accountinfo['refill_amount']) && $accountinfo['refill_amount'] != "") {
1072 1072
 			$refillamount = $accountinfo['refill_amount'];
1073
-		} else{
1073
+		} else {
1074 1074
 			$refillamount = "0";
1075 1075
 		}
1076 1076
 		
1077 1077
 		switch ($type) {
1078 1078
 			case 'email_add_user':
1079
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1079
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1080 1080
 				$message = str_replace('#NUMBER#', $accountinfo['number'], $message);
1081 1081
 				$message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1082 1082
 				$message = str_replace('#LINK#', $accountinfo['confirm'], $message);
1083 1083
 				break;
1084 1084
 			case 'email_forgot_user':
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('#NUMBER#', $accountinfo['number'], $message);
1087 1087
 				$message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1088 1088
 				$message = str_replace('#LINK#', $accountinfo['link'], $message);
1089 1089
 				break;
1090 1090
 
1091 1091
 			case 'email_forgot_confirmation':
1092
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1092
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1093 1093
 				$message = str_replace('#CONFIRM#', $accountinfo['confirm'], $message);
1094 1094
 				break;
1095 1095
 
1096 1096
 			case 'email_signup_confirmation':
1097
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1097
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1098 1098
 				$message = str_replace('#CONFIRM#', $accountinfo['confirm'], $message);
1099 1099
 				break;
1100 1100
 			case 'add_sip_device':
1101
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1101
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1102 1102
 				$message = str_replace('#USERNAME#', $accountinfo['number'], $message);
1103 1103
 				$message = str_replace('#PASSWORD#', $accountinfo['password'], $message);
1104 1104
 				break;
1105 1105
                               
1106 1106
 			case 'voip_account_refilled':
1107
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1107
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1108 1108
 				$message = str_replace('#REFILLBALANCE#', $accountinfo['refill_amount'], $message);
1109 1109
 				$message = str_replace('#BALANCE#', $accountinfo['refill_amount'] + $accountinfo['balance'], $message);
1110 1110
 				break;
1111 1111
 			case 'voip_child_account_refilled':
1112
-				$reseller_number= $this->CI->common->get_field_name('number', 'accounts', $accountinfo['reseller_id']);
1113
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1112
+				$reseller_number = $this->CI->common->get_field_name('number', 'accounts', $accountinfo['reseller_id']);
1113
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1114 1114
 				$message = str_replace('#REFILLBALANCE#', $accountinfo['refill_amount'], $message);
1115 1115
 				$message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1116
-				$message = str_replace('#ACCOUNTNUMBER#',$reseller_number, $message);
1116
+				$message = str_replace('#ACCOUNTNUMBER#', $reseller_number, $message);
1117 1117
 				break;
1118 1118
 			case 'add_subscription':
1119
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1119
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1120 1120
 				break;
1121 1121
 			case 'remove_subscription':
1122
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1122
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1123 1123
 				break;
1124 1124
 			case 'add_package':
1125
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1125
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1126 1126
 				break;
1127 1127
 			case 'remove_package':
1128
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1128
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1129 1129
 				break;
1130 1130
 			case 'email_calling_card':
1131
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1131
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1132 1132
 				$message = str_replace('#CARDNUMBER#', $accountinfo['cardnumber'], $message);
1133 1133
 				$message = str_replace('#PIN#', $accountinfo['pin'], $message);
1134 1134
 				$message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1135 1135
 				break;
1136 1136
 			case 'email_low_balance';
1137
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1137
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1138 1138
 				$to_currency = $this->CI->common->get_field_name('currency', 'currency', $accountinfo['currency_id']);
1139 1139
 				$balance = $this->CI->common_model->calculate_currency($accountinfo['balance'], "", $to_currency, true, true);
1140 1140
 				$message = str_replace('#BALANCE#', $accountinfo['balance'], $message);
1141 1141
 				break;
1142 1142
 			case 'email_new_invoice';
1143
-				$message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1143
+				$message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1144 1144
 				$message = str_replace('#AMOUNT#', $amount, $message);
1145 1145
 				$message = str_replace('#INVOICE_NUMBER#', $amount, $message);
1146 1146
 				$subject = $query[0]->subject;
1147 1147
 				$subject = str_replace("#INVOICE_NUMBER#", $amount, $subject);
1148 1148
 				break;
1149 1149
 			 case 'email_add_did';
1150
-				if(isset($accountinfo['did_maxchannels']) && $accountinfo['did_maxchannels']!= ""){
1150
+				if (isset($accountinfo['did_maxchannels']) && $accountinfo['did_maxchannels'] != "") {
1151 1151
 					$accountinfo['did_maxchannels'] = $accountinfo['did_maxchannels'];
1152
-				} else if($accountinfo['did_maxchannels'] == "0"){
1152
+				} else if ($accountinfo['did_maxchannels'] == "0") {
1153 1153
 							$accountinfo['did_maxchannels'] = "Unlimited";
1154
-				} else{
1154
+				} else {
1155 1155
 					$accountinfo['did_maxchannels'] = "Unlimited";
1156 1156
 				}
1157
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1158
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'] , $message);
1159
-                $message = str_replace('#COUNTRYNAME#',$accountinfo['did_country_id'], $message);
1160
-                $message = str_replace('#SETUPFEE#',$accountinfo['did_setup'], $message);
1161
-                $message = str_replace('#MONTHLYFEE#',$accountinfo['did_monthlycost'], $message);
1162
-                $message = str_replace('#MAXCHANNEL#',$accountinfo['did_maxchannels'], $message);
1157
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1158
+                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'], $message);
1159
+                $message = str_replace('#COUNTRYNAME#', $accountinfo['did_country_id'], $message);
1160
+                $message = str_replace('#SETUPFEE#', $accountinfo['did_setup'], $message);
1161
+                $message = str_replace('#MONTHLYFEE#', $accountinfo['did_monthlycost'], $message);
1162
+                $message = str_replace('#MAXCHANNEL#', $accountinfo['did_maxchannels'], $message);
1163 1163
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1164 1164
 				$subject = $query[0]->subject;
1165 1165
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
1166 1166
 				$subject = str_replace("#DIDNUMBER#", $accountinfo['did_number'], $subject);
1167 1167
                 break;
1168 1168
             case 'email_remove_did';
1169
-                $message = str_replace('#NAME#', $accountinfo['first_name'] . " " . $accountinfo['last_name'], $message);
1170
-                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'],$message);
1169
+                $message = str_replace('#NAME#', $accountinfo['first_name']." ".$accountinfo['last_name'], $message);
1170
+                $message = str_replace('#DIDNUMBER#', $accountinfo['did_number'], $message);
1171 1171
                 $message = str_replace('#NUMBER#', $accountinfo['number'], $message);	
1172 1172
 				$subject = $query[0]->subject;
1173 1173
 				$subject = str_replace("#NUMBER#", $accountinfo['number'], $subject);
@@ -1766,90 +1766,90 @@  discard block
 block discarded – undo
1766 1766
     }
1767 1767
     /* ASTPP  3.0  Remove all information related to going to delete customer.
1768 1768
      */
1769
-    function customer_delete_dependencies($id){
1770
-          $this->delete_data('ani_map',array('accountid'=>$id));
1771
-          $this->delete_data('block_patterns',array('accountid'=>$id));
1772
-          $this->delete_data('charge_to_account',array('accountid'=>$id));
1773
-          $this->delete_data('counters',array('accountid'=>$id));
1774
-          $this->delete_data('ip_map',array('accountid'=>$id));
1775
-          $this->delete_data('sip_devices',array('accountid'=>$id));
1776
-          $this->delete_data('speed_dial',array('accountid'=>$id));
1777
-          $this->delete_data('taxes_to_accounts',array('accountid'=>$id));
1778
-          $this->delete_data('mail_details',array('accountid'=>$id));
1779
-          $this->update_data('dids',array("accountid"=>$id),array('accountid'=>0));
1780
-          $this->update_data("accounts",array("id"=>$id),array("deleted"=>1));
1769
+    function customer_delete_dependencies($id) {
1770
+          $this->delete_data('ani_map', array('accountid'=>$id));
1771
+          $this->delete_data('block_patterns', array('accountid'=>$id));
1772
+          $this->delete_data('charge_to_account', array('accountid'=>$id));
1773
+          $this->delete_data('counters', array('accountid'=>$id));
1774
+          $this->delete_data('ip_map', array('accountid'=>$id));
1775
+          $this->delete_data('sip_devices', array('accountid'=>$id));
1776
+          $this->delete_data('speed_dial', array('accountid'=>$id));
1777
+          $this->delete_data('taxes_to_accounts', array('accountid'=>$id));
1778
+          $this->delete_data('mail_details', array('accountid'=>$id));
1779
+          $this->update_data('dids', array("accountid"=>$id), array('accountid'=>0));
1780
+          $this->update_data("accounts", array("id"=>$id), array("deleted"=>1));
1781 1781
     }
1782 1782
     /*
1783 1783
      *  ASTPP  3.0 
1784 1784
      *  Remove all information related to going to delete reseller.
1785 1785
      */
1786
-    function reseller_delete_dependencies($id){
1787
-        $accountinfo=$this->CI->session->userdata('accountinfo');
1788
-        $child_arr=$this->select_data("accounts",array("reseller_id"=>$id,"type"=>0),'id,reseller_id');
1789
-        if($child_arr){
1790
-            foreach($child_arr as $value){
1786
+    function reseller_delete_dependencies($id) {
1787
+        $accountinfo = $this->CI->session->userdata('accountinfo');
1788
+        $child_arr = $this->select_data("accounts", array("reseller_id"=>$id, "type"=>0), 'id,reseller_id');
1789
+        if ($child_arr) {
1790
+            foreach ($child_arr as $value) {
1791 1791
                 $this->customer_delete_dependencies($value['id']);
1792 1792
             }
1793 1793
         }
1794
-        $package_arr=$this->select_data("packages",array("reseller_id"=>$id),'id');
1795
-        if($package_arr){
1796
-            foreach($package_arr as $value){
1797
-                $this->delete_data('package_patterns',array("id"=>$value['id']));
1794
+        $package_arr = $this->select_data("packages", array("reseller_id"=>$id), 'id');
1795
+        if ($package_arr) {
1796
+            foreach ($package_arr as $value) {
1797
+                $this->delete_data('package_patterns', array("id"=>$value['id']));
1798 1798
             }
1799 1799
         }
1800
-        $acc_arr=$this->select_data('accounts',array("id"=>$id),'id,reseller_id');
1801
-        $parent_id=0;
1802
-        if($acc_arr){
1803
-            $parent_id=$acc_arr[0]['reseller_id'];
1800
+        $acc_arr = $this->select_data('accounts', array("id"=>$id), 'id,reseller_id');
1801
+        $parent_id = 0;
1802
+        if ($acc_arr) {
1803
+            $parent_id = $acc_arr[0]['reseller_id'];
1804 1804
         }
1805
-        $pricelist_arr=$this->select_data('pricelists',array('reseller_id'=>$id),'id');
1806
-        if($pricelist_arr){
1807
-             foreach($pricelist_arr as $value){
1808
-                $this->delete_data("routing",array("pricelist_id"=>$value['id']));
1809
-                $this->delete_data("routes",array("pricelist_id"=>$value['id']));
1810
-                $this->update_data('pricelists',array('id'=>$value['id']),array('status'=>2));         
1805
+        $pricelist_arr = $this->select_data('pricelists', array('reseller_id'=>$id), 'id');
1806
+        if ($pricelist_arr) {
1807
+             foreach ($pricelist_arr as $value) {
1808
+                $this->delete_data("routing", array("pricelist_id"=>$value['id']));
1809
+                $this->delete_data("routes", array("pricelist_id"=>$value['id']));
1810
+                $this->update_data('pricelists', array('id'=>$value['id']), array('status'=>2));         
1811 1811
              }
1812 1812
         }
1813
-        $charge_arr=$this->select_data('charges',array('reseller_id'=>$id),'id');
1814
-        if($charge_arr){
1815
-             foreach($charge_arr as $value){
1816
-                $this->delete_data("charge_to_account",array("charge_id"=>$value['id']));
1813
+        $charge_arr = $this->select_data('charges', array('reseller_id'=>$id), 'id');
1814
+        if ($charge_arr) {
1815
+             foreach ($charge_arr as $value) {
1816
+                $this->delete_data("charge_to_account", array("charge_id"=>$value['id']));
1817 1817
              }
1818 1818
         }
1819
-        $this->delete_data('charges',array('reseller_id'=>$id));
1820
-        $this->update_data('dids',array('parent_id'=>$id),array("parent_id"=>$parent_id));
1821
-        $this->delete_data('reseller_pricing',array("reseller_id"=>$id));
1822
-        $this->delete_data('refill_coupon',array("reseller_id"=>$id));
1823
-        $this->delete_data('mail_details',array('accountid'=>$id));
1824
-        $taxes_arr=$this->select_data('taxes',array("reseller_id"=>$id),'id');
1825
-        if($taxes_arr){
1826
-             foreach($taxes_arr as $value){
1827
-                $this->delete_data("taxes_to_accounts",array("taxes_id"=>$value['id']));
1819
+        $this->delete_data('charges', array('reseller_id'=>$id));
1820
+        $this->update_data('dids', array('parent_id'=>$id), array("parent_id"=>$parent_id));
1821
+        $this->delete_data('reseller_pricing', array("reseller_id"=>$id));
1822
+        $this->delete_data('refill_coupon', array("reseller_id"=>$id));
1823
+        $this->delete_data('mail_details', array('accountid'=>$id));
1824
+        $taxes_arr = $this->select_data('taxes', array("reseller_id"=>$id), 'id');
1825
+        if ($taxes_arr) {
1826
+             foreach ($taxes_arr as $value) {
1827
+                $this->delete_data("taxes_to_accounts", array("taxes_id"=>$value['id']));
1828 1828
              }
1829 1829
         }
1830
-        $this->delete_data('taxes',array("reseller_id"=>$id));
1831
-        $this->delete_data('default_templates',array("reseller_id"=>$id));
1832
-        $package_arr=$this->select_data('packages',array('reseller_id'=>$id),'id');
1833
-        if($package_arr){
1834
-            $this->delete_data("counters",array("package_id"=>$value['id']));
1835
-            $this->delete_data("package_patterns",array("package_id"=>$value['id']));
1830
+        $this->delete_data('taxes', array("reseller_id"=>$id));
1831
+        $this->delete_data('default_templates', array("reseller_id"=>$id));
1832
+        $package_arr = $this->select_data('packages', array('reseller_id'=>$id), 'id');
1833
+        if ($package_arr) {
1834
+            $this->delete_data("counters", array("package_id"=>$value['id']));
1835
+            $this->delete_data("package_patterns", array("package_id"=>$value['id']));
1836 1836
         }
1837
-        $this->delete_data('invoice_conf',array('accountid'=>$id));
1838
-        $this->delete_data('packages',array("reseller_id"=>$id));
1839
-        $this->update_data('accounts',array("id"=>$id),array("deleted"=>1));
1837
+        $this->delete_data('invoice_conf', array('accountid'=>$id));
1838
+        $this->delete_data('packages', array("reseller_id"=>$id));
1839
+        $this->update_data('accounts', array("id"=>$id), array("deleted"=>1));
1840 1840
     }
1841 1841
     function subreseller_list($parent_id = '') {
1842 1842
         $customer_id = $parent_id;
1843 1843
         $this->reseller_delete_dependencies($parent_id);
1844
-        $query = 'select id,type from accounts where reseller_id = ' . $parent_id .' AND deleted =0';
1844
+        $query = 'select id,type from accounts where reseller_id = '.$parent_id.' AND deleted =0';
1845 1845
         $result = $this->CI->db->query($query);
1846 1846
         if ($result->num_rows() > 0) {
1847 1847
             $result = $result->result_array();
1848 1848
             foreach ($result as $data) {
1849
-	      if($data['type']==1){
1849
+	      if ($data['type'] == 1) {
1850 1850
 		  $this->reseller_delete_dependencies($data['id']);
1851 1851
 		  $this->subreseller_list($data['id']);
1852
-	      } else{
1852
+	      } else {
1853 1853
 		  $this->customer_delete_dependencies($data['id']);
1854 1854
 	      }
1855 1855
             }
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
     /**
1860 1860
      * @param string $table_name
1861 1861
      */
1862
-    function delete_data($table_name,$where_arr){
1862
+    function delete_data($table_name, $where_arr) {
1863 1863
         $this->CI->db->where($where_arr);
1864 1864
         $this->CI->db->delete($table_name);
1865 1865
     }
@@ -1867,22 +1867,22 @@  discard block
 block discarded – undo
1867 1867
     /**
1868 1868
      * @param string $table_name
1869 1869
      */
1870
-    function update_data($table_name,$where_arr,$update_arr){
1870
+    function update_data($table_name, $where_arr, $update_arr) {
1871 1871
         $this->CI->db->where($where_arr);
1872
-        $this->CI->db->update($table_name,$update_arr);
1872
+        $this->CI->db->update($table_name, $update_arr);
1873 1873
     }
1874 1874
 
1875 1875
     /**
1876 1876
      * @param string $table_name
1877 1877
      * @param string $select
1878 1878
      */
1879
-    function select_data($table_name,$where_arr,$select){
1879
+    function select_data($table_name, $where_arr, $select) {
1880 1880
         $this->CI->db->where($where_arr);
1881 1881
         $this->CI->db->select($select);
1882
-        $result=$this->CI->db->get($table_name);
1883
-        if($result->num_rows() > 0){
1882
+        $result = $this->CI->db->get($table_name);
1883
+        if ($result->num_rows() > 0) {
1884 1884
             return $result->result_array();
1885
-        } else{
1885
+        } else {
1886 1886
             return false;
1887 1887
         }
1888 1888
     }
@@ -1894,82 +1894,82 @@  discard block
 block discarded – undo
1894 1894
     function get_call_waiting($select = "", $table = "", $status) {
1895 1895
         return ($status == 0) ? "Enable" : "Disable";
1896 1896
 	}
1897
-  function set_invoice_details($select= ''){
1897
+  function set_invoice_details($select = '') {
1898 1898
         $status_array = array("invoice_select" => "--Select--",
1899 1899
             "invoice_inactive" => "Deleted Invoices",
1900 1900
             "invoice_active" => "All Invoices",
1901 1901
         );
1902 1902
         return $status_array;
1903 1903
 }
1904
-function get_invoice_template($invoicedata,$accountdata,$flag){
1904
+function get_invoice_template($invoicedata, $accountdata, $flag) {
1905 1905
       $login_info = $this->CI->session->userdata('accountinfo');
1906 1906
 
1907 1907
       $invoice_config = $this->CI->db_model->getSelect("*", "invoice_conf", array('accountid'=>$login_info['id']));
1908
-      $invoice_config= $invoice_config->result_array();
1909
-      $invoice_config_res= $invoice_config[0];
1908
+      $invoice_config = $invoice_config->result_array();
1909
+      $invoice_config_res = $invoice_config[0];
1910 1910
 
1911 1911
       $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $accountdata["currency_id"]);
1912 1912
       $accountdata["country"] = $this->get_field_name('country', 'countrycode', $accountdata["country_id"]);
1913 1913
       $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
1914
-      if($login_info['type'] == -1){
1914
+      if ($login_info['type'] == -1) {
1915 1915
           $currency = $data["to_currency"];
1916
-      } elseif($login_info['type'] == 1){
1916
+      } elseif ($login_info['type'] == 1) {
1917 1917
 	  $accountdata["currency_id"] = $this->get_field_name('currency', 'currency', $login_info["currency_id"]);
1918 1918
           $currency = $accountdata["currency_id"];
1919
-      } else{
1919
+      } else {
1920 1920
           $currency = $accountdata["currency_id"];
1921 1921
       }
1922
-      $decimal_amount=Common_model::$global_config['system_config']['decimalpoints'];
1922
+      $decimal_amount = Common_model::$global_config['system_config']['decimalpoints'];
1923 1923
       ob_start();
1924 1924
       $this->CI->load->library('/html2pdf/html2pdf');
1925
-      $this->CI->html2pdf = new HTML2PDF('P','A4','en');
1925
+      $this->CI->html2pdf = new HTML2PDF('P', 'A4', 'en');
1926 1926
       $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
1927
-      $template_config=$this->CI->config->item('invoice_template');
1927
+      $template_config = $this->CI->config->item('invoice_template');
1928 1928
       include($template_config.'invoice_template.php');
1929 1929
       $content = ob_get_clean();
1930 1930
       ob_clean();
1931 1931
 
1932 1932
 	$ACCOUNTADD = '';
1933
-	$ACCOUNTADD_CUSTOMER ='';
1933
+	$ACCOUNTADD_CUSTOMER = '';
1934 1934
 	$ACCOUNTADD_RIGHT = '';
1935 1935
 	$ACCOUNT_DESCRIPTION = '';
1936 1936
 	$ACCOUNT_CDRS = '';
1937
-	$ACCOUNT_TOTAL= '';
1937
+	$ACCOUNT_TOTAL = '';
1938 1938
 	$ACCOUNT_TOTAL_FINAL = '';
1939 1939
 	$ACCOUNT_FINAL = '';
1940
-	$CHARGE_ACCOUNT ='';
1940
+	$CHARGE_ACCOUNT = '';
1941 1941
 	$service_info = '';
1942 1942
 	$TotalChrg = "0.00";
1943 1943
 	$NETAMT = "0.00";
1944 1944
 	$TAXAMT = "0.00";
1945
-	$total_sum=0;
1946
-	$total_vat=0;
1945
+	$total_sum = 0;
1946
+	$total_vat = 0;
1947 1947
 	$fromdate = strtotime($invoicedata['from_date']);
1948
-	$from_date =date("Y-m-d",$fromdate);
1948
+	$from_date = date("Y-m-d", $fromdate);
1949 1949
 	$duedate = strtotime($invoicedata['due_date']);
1950
-	$due_date =date("Y-m-d",$duedate);
1950
+	$due_date = date("Y-m-d", $duedate);
1951 1951
 
1952 1952
 /*************************** Company Address Code START ***************************************************/
1953 1953
 		$ACCOUNTADD .= '<tr>';
1954 1954
 		$ACCOUNTADD .= '<td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;"><b>'.$invoice_config_res['company_name'].'</b></td>';
1955 1955
 		$ACCOUNTADD .= '</tr>';
1956
-	if ( $invoice_config_res['address'] != ""){
1956
+	if ($invoice_config_res['address'] != "") {
1957 1957
 
1958 1958
 		$ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['address'].'</td></tr>';
1959 1959
 	}
1960
-	if ( $invoice_config_res['city'] != ""){
1960
+	if ($invoice_config_res['city'] != "") {
1961 1961
 
1962 1962
 		$ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['city'].'</td></tr>';
1963 1963
 	}
1964
-	if ( $invoice_config_res['province'] != ""){
1964
+	if ($invoice_config_res['province'] != "") {
1965 1965
 
1966 1966
 		$ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['province'].'</td></tr>';
1967 1967
 	}
1968
-	if ( $invoice_config_res['country'] != ""){
1968
+	if ($invoice_config_res['country'] != "") {
1969 1969
 
1970 1970
 		$ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['country'].'</td></tr>';
1971 1971
 	}
1972
-	if ( $invoice_config_res['zipcode'] != ""){
1972
+	if ($invoice_config_res['zipcode'] != "") {
1973 1973
 
1974 1974
 		$ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$invoice_config_res['zipcode'].'</td></tr>';
1975 1975
 	}
@@ -1980,27 +1980,27 @@  discard block
 block discarded – undo
1980 1980
 		$ACCOUNTADD_CUSTOMER .= '<table><tr>';
1981 1981
 		$ACCOUNTADD_CUSTOMER .= '<td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;"><b>'.$accountdata['company_name'].'</b></td></tr>';
1982 1982
 
1983
-	if ( $accountdata['address_1'] != ""){
1983
+	if ($accountdata['address_1'] != "") {
1984 1984
 
1985 1985
 		$ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['address_1'].'</td></tr>';
1986 1986
 	}
1987
-	if ( $accountdata['city'] != ""){
1987
+	if ($accountdata['city'] != "") {
1988 1988
 
1989 1989
 		$ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['city'].'</td></tr>';
1990 1990
 	}
1991
-	if ( $accountdata['province'] != ""){
1991
+	if ($accountdata['province'] != "") {
1992 1992
 
1993 1993
 		$ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['province'].'</td></tr>';
1994 1994
 	}
1995
-	if ( $accountdata['country'] != ""){
1995
+	if ($accountdata['country'] != "") {
1996 1996
 
1997 1997
 		$ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['country'].'</td></tr>';
1998 1998
 	}
1999
-	if ( $accountdata['postal_code'] != ""){
1999
+	if ($accountdata['postal_code'] != "") {
2000 2000
 
2001 2001
 		$ACCOUNTADD_CUSTOMER .= '<tr><td style="width:100%;font-size: 12px;color:#525252;font-family:arial; line-height: 22px;">'.$accountdata['postal_code'].'</td></tr>';
2002 2002
 	}
2003
-	$ACCOUNTADD_CUSTOMER .="</table>"; 
2003
+	$ACCOUNTADD_CUSTOMER .= "</table>"; 
2004 2004
 /*************************** Customer Address Code END ***************************************************/
2005 2005
 
2006 2006
 
@@ -2010,7 +2010,7 @@  discard block
 block discarded – undo
2010 2010
 	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Date</td>';
2011 2011
 		$ACCOUNT_DESCRIPTION .= '<td  style="width:40%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Description</td>';
2012 2012
 		$ACCOUNT_DESCRIPTION .= '<td  style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Charge Type</td>';
2013
-	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency .')</td>';
2013
+	$ACCOUNT_DESCRIPTION .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency.')</td>';
2014 2014
 		$ACCOUNT_DESCRIPTION .= '</tr>';
2015 2015
 
2016 2016
 
@@ -2018,23 +2018,23 @@  discard block
 block discarded – undo
2018 2018
 	$ACCOUNT_CDRS .= '<td style="width:40%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Description</td>';
2019 2019
 	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Duration (Seconds)</td>';
2020 2020
 		$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;">Total Calls</td>';
2021
-	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency .')</td>';
2021
+	$ACCOUNT_CDRS .= '<td style="width:20%;font-size: 12px;color:#fff;font-family:arial; line-height: 22px;text-align:right;">Amount ('.$currency.')</td>';
2022 2022
 		$ACCOUNT_CDRS .= '</tr>';
2023 2023
 
2024 2024
 	/*** manual invoice **/
2025
-	$this->CI->db->where('item_type <>','INVPAY');
2026
-		$invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details',array("invoiceid"=> $invoicedata['id'],'item_type <>'=> 'TAX' ));
2027
-	$invoice_details= $invoice_details->result_array();
2028
-	$total_sum=0;
2029
-	foreach($invoice_details as $charge_res){
2030
-		if($charge_res['item_type'] == 'DIDCHRG' || $charge_res['item_type'] == 'SUBCHRG' || $charge_res['item_type'] == 'manual_inv' ){
2031
-		if($charge_res['item_type'] == 'manual_inv'){
2025
+	$this->CI->db->where('item_type <>', 'INVPAY');
2026
+		$invoice_details = $this->CI->db_model->getSelect('*', 'invoice_details', array("invoiceid"=> $invoicedata['id'], 'item_type <>'=> 'TAX'));
2027
+	$invoice_details = $invoice_details->result_array();
2028
+	$total_sum = 0;
2029
+	foreach ($invoice_details as $charge_res) {
2030
+		if ($charge_res['item_type'] == 'DIDCHRG' || $charge_res['item_type'] == 'SUBCHRG' || $charge_res['item_type'] == 'manual_inv') {
2031
+		if ($charge_res['item_type'] == 'manual_inv') {
2032 2032
 			$charge_res['item_type'] = 'Manual Invoice';
2033 2033
 		}
2034
-		if($charge_res['item_type'] == 'DIDCHRG'){
2034
+		if ($charge_res['item_type'] == 'DIDCHRG') {
2035 2035
 			$charge_res['item_type'] = 'DID Charge';
2036 2036
 		}
2037
-		if($charge_res['item_type'] == 'SUBCHRG'){
2037
+		if ($charge_res['item_type'] == 'SUBCHRG') {
2038 2038
 			$charge_res['item_type'] = 'Subscription Charge';
2039 2039
 		}
2040 2040
 
@@ -2045,12 +2045,12 @@  discard block
 block discarded – undo
2045 2045
 
2046 2046
 		$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>';
2047 2047
 		$ACCOUNT_DESCRIPTION .= '</tr>';
2048
-		 }else{
2049
-			$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']));
2048
+		 } else {
2049
+			$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']));
2050 2050
 			$cdrs_result = $cdrs_data->result_array();
2051
-		if($cdrs_result[0]['count'] > 0 ){
2052
-		$cdrs_record_count=$cdrs_result[0]['count'] ;
2053
-		$cdrs_record_billseconds=$cdrs_result[0]['billseconds'] ;
2051
+		if ($cdrs_result[0]['count'] > 0) {
2052
+		$cdrs_record_count = $cdrs_result[0]['count'];
2053
+		$cdrs_record_billseconds = $cdrs_result[0]['billseconds'];
2054 2054
 /*echo '<pre>'.$cdrs_record_count;
2055 2055
 print_r($cdrs_result);
2056 2056
 exit;*/
@@ -2068,8 +2068,8 @@  discard block
 block discarded – undo
2068 2068
 
2069 2069
 /**********************************Tax Apply Start********************************************************************/
2070 2070
 	$total_sum = $total_sum;
2071
-	$total_sum=$this->currency_decimal($this->CI->common_model->calculate_currency($total_sum));
2072
-		$invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details',array("invoiceid"=> $invoicedata['id'],'item_type '=> 'TAX'));
2071
+	$total_sum = $this->currency_decimal($this->CI->common_model->calculate_currency($total_sum));
2072
+		$invoice_tax = $this->CI->db_model->getSelect('*', 'invoice_details', array("invoiceid"=> $invoicedata['id'], 'item_type '=> 'TAX'));
2073 2073
  	//$ACCOUNT_TOTAL .= '<td><table style="width:100%;margin-left:360px;">';
2074 2074
 
2075 2075
 	$ACCOUNT_TOTAL .= '<tr>';
@@ -2136,26 +2136,26 @@  discard block
 block discarded – undo
2136 2136
 
2137 2137
 /*************************** Invoice Note Code END ***************************************************/
2138 2138
 		$invoice_notes = $this->CI->db_model->getSelect('*', 'invoices', array('id'=>$invoicedata['id']));
2139
-		$invoice_notes=$invoice_notes->result_array();
2140
-	if(isset($invoice_notes[0]['notes'])){
2141
-		$invoice_notes=$invoice_notes[0]['notes'];
2142
-	} else{
2143
-		if($invoice_notes[0]['invoice_note'] == '0' ){
2144
-			$invoice_notes='THIS IS A 30 DAY ACCOUNT, SO PLEASE MAKE PAYMENT WITHIN THESE TERMS';
2145
-		} else{
2146
-			$invoice_notes=$invoice_notes[0]['invoice_note'];
2139
+		$invoice_notes = $invoice_notes->result_array();
2140
+	if (isset($invoice_notes[0]['notes'])) {
2141
+		$invoice_notes = $invoice_notes[0]['notes'];
2142
+	} else {
2143
+		if ($invoice_notes[0]['invoice_note'] == '0') {
2144
+			$invoice_notes = 'THIS IS A 30 DAY ACCOUNT, SO PLEASE MAKE PAYMENT WITHIN THESE TERMS';
2145
+		} else {
2146
+			$invoice_notes = $invoice_notes[0]['invoice_note'];
2147 2147
 		}
2148 2148
 	}
2149 2149
 /*************************** Invoice Note Code END ***************************************************/
2150 2150
 
2151 2151
 	if (file_exists(getcwd()."/upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'])) {
2152
-		if($invoice_config[0]['logo'] != ''){
2153
-			$content = str_replace("<LOGO>",base_url()."upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'],$content);
2154
-		} else{
2155
-			$content = str_replace("<LOGO>",base_url().'/assets/images/logo.png',$content);
2152
+		if ($invoice_config[0]['logo'] != '') {
2153
+			$content = str_replace("<LOGO>", base_url()."upload/".$invoice_config[0]['accountid']."_".$invoice_config[0]['logo'], $content);
2154
+		} else {
2155
+			$content = str_replace("<LOGO>", base_url().'/assets/images/logo.png', $content);
2156 2156
 		}
2157
-	} else{
2158
-		$content = str_replace("<LOGO>",base_url().'/assets/images/logo.png',$content);
2157
+	} else {
2158
+		$content = str_replace("<LOGO>", base_url().'/assets/images/logo.png', $content);
2159 2159
 	}
2160 2160
 
2161 2161
 	$ACCOUNT_TOTAL_FINAL .= '<tr>';
@@ -2164,37 +2164,37 @@  discard block
 block discarded – undo
2164 2164
 	$ACCOUNT_TOTAL_FINAL .= '</tr>';
2165 2165
 
2166 2166
 	  //  $content = str_replace("<LOGO>",$image_logo,$content);   
2167
-		$content = str_replace("<ACCOUNTADD>",$ACCOUNTADD,$content);
2168
-		$content = str_replace("<ACCOUNTADD_CUSTOMER>",$ACCOUNTADD_CUSTOMER,$content);
2169
-		$content = str_replace("<ACCOUNTADD_RIGHT>",$ACCOUNTADD_RIGHT,$content);
2170
-	$content = str_replace("<ACCOUNT_DESCRIPTION>",$ACCOUNT_DESCRIPTION,$content);
2171
-	$content = str_replace("<ACCOUNT_CDRS>",$ACCOUNT_CDRS,$content);
2172
-	$content = str_replace("<ACCOUNT_TOTAL>",$ACCOUNT_TOTAL,$content);
2173
-	$content = str_replace("<ACCOUNT_TOTAL_FINAL>",$ACCOUNT_TOTAL_FINAL,$content);
2174
-		$content = str_replace("<NOTES>",$invoice_notes,$content);
2167
+		$content = str_replace("<ACCOUNTADD>", $ACCOUNTADD, $content);
2168
+		$content = str_replace("<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content);
2169
+		$content = str_replace("<ACCOUNTADD_RIGHT>", $ACCOUNTADD_RIGHT, $content);
2170
+	$content = str_replace("<ACCOUNT_DESCRIPTION>", $ACCOUNT_DESCRIPTION, $content);
2171
+	$content = str_replace("<ACCOUNT_CDRS>", $ACCOUNT_CDRS, $content);
2172
+	$content = str_replace("<ACCOUNT_TOTAL>", $ACCOUNT_TOTAL, $content);
2173
+	$content = str_replace("<ACCOUNT_TOTAL_FINAL>", $ACCOUNT_TOTAL_FINAL, $content);
2174
+		$content = str_replace("<NOTES>", $invoice_notes, $content);
2175 2175
 
2176 2176
 //echo $content; exit;
2177 2177
 
2178
-	$invoice_path=$this->CI->config->item('invoices_path');
2178
+	$invoice_path = $this->CI->config->item('invoices_path');
2179 2179
 	$download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; 
2180 2180
 	   //echo  $download_path; exit;
2181 2181
 	   $this->CI->html2pdf->pdf->SetDisplayMode('fullpage');
2182 2182
 	   $this->CI->html2pdf->writeHTML($content);
2183 2183
        
2184
-	   if($flag== 'TRUE'){
2184
+	   if ($flag == 'TRUE') {
2185 2185
 		$download_path = $invoicedata['invoice_prefix'].$invoicedata['invoiceid'].".pdf";
2186 2186
        
2187
-		$this->CI->html2pdf->Output($download_path,"D");        
2188
-	   }else{
2187
+		$this->CI->html2pdf->Output($download_path, "D");        
2188
+	   } else {
2189 2189
 		$current_dir = getcwd()."/invoices/";
2190 2190
 		$dir_name = $accountdata["id"];
2191
-		if(!is_dir($current_dir.$dir_name)){
2192
-				mkdir($current_dir.$dir_name,0777, true);
2191
+		if ( ! is_dir($current_dir.$dir_name)) {
2192
+				mkdir($current_dir.$dir_name, 0777, true);
2193 2193
 				chmod($current_dir.$dir_name, 0777);        
2194 2194
 		}        
2195
-		$invoice_path=$this->CI->config->item('invoices_path');
2195
+		$invoice_path = $this->CI->config->item('invoices_path');
2196 2196
 		$download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; 
2197
-		$this->CI->html2pdf->Output($download_path,"F");         
2197
+		$this->CI->html2pdf->Output($download_path, "F");         
2198 2198
 	   }
2199 2199
 }
2200 2200
 	function reseller_select_value($select, $table, $id_where = '') {
@@ -2214,55 +2214,55 @@  discard block
 block discarded – undo
2214 2214
 	   return 'Admin';
2215 2215
 	}
2216 2216
     
2217
-	function get_subreseller_info($parent_id){
2218
-		if(!empty($parent_id)){
2219
-	  $str=$parent_id.",";
2220
-		}else{
2221
-		  $str=null;
2217
+	function get_subreseller_info($parent_id) {
2218
+		if ( ! empty($parent_id)) {
2219
+	  $str = $parent_id.",";
2220
+		} else {
2221
+		  $str = null;
2222 2222
 		}
2223 2223
 		$query = "select id from accounts where reseller_id = '$parent_id' AND deleted =0 AND type=1";
2224 2224
 		$result = $this->CI->db->query($query);
2225
-		if($result->num_rows() > 0){
2225
+		if ($result->num_rows() > 0) {
2226 2226
 		$result = $result->result_array();
2227
-	  foreach ($result as $data){
2228
-		if(!empty($data['id'])){
2229
-		  $str.=$this->get_subreseller_info($data['id']);
2227
+	  foreach ($result as $data) {
2228
+		if ( ! empty($data['id'])) {
2229
+		  $str .= $this->get_subreseller_info($data['id']);
2230 2230
 		}
2231 2231
 	  }
2232 2232
 	}
2233 2233
 	return $str;
2234 2234
 	}
2235
-	function get_parent_info($child_id,$parent_id){
2236
-		if(!empty($child_id)){
2237
-	  $str=$child_id.",";
2238
-		}else{
2239
-		  $str=null;
2235
+	function get_parent_info($child_id, $parent_id) {
2236
+		if ( ! empty($child_id)) {
2237
+	  $str = $child_id.",";
2238
+		} else {
2239
+		  $str = null;
2240 2240
 		}
2241
-		if($child_id > 0){
2241
+		if ($child_id > 0) {
2242 2242
 		$query = "select reseller_id from accounts where id = '$child_id'";
2243 2243
 		$result = $this->CI->db->query($query);
2244
-		if($result->num_rows() > 0){
2244
+		if ($result->num_rows() > 0) {
2245 2245
 		$parent_info = (array)$result->first_row();
2246
-	  if($parent_info['reseller_id'] != $parent_id){
2247
-		$str.=$this->get_parent_info($parent_info['reseller_id'],$parent_id);
2246
+	  if ($parent_info['reseller_id'] != $parent_id) {
2247
+		$str .= $this->get_parent_info($parent_info['reseller_id'], $parent_id);
2248 2248
 	  }
2249 2249
 	}
2250 2250
 	}
2251 2251
 	return $str;
2252 2252
 	}
2253
-	function get_did_accountid($select,$table,$where){
2254
-	  $accountinfo=$this->CI->session->userdata('accountinfo');
2255
-	  $this->CI->db->where('note',$where);
2256
-	  $this->CI->db->where('parent_id',$accountinfo['id']);
2253
+	function get_did_accountid($select, $table, $where) {
2254
+	  $accountinfo = $this->CI->session->userdata('accountinfo');
2255
+	  $this->CI->db->where('note', $where);
2256
+	  $this->CI->db->where('parent_id', $accountinfo['id']);
2257 2257
 	  $this->CI->db->select('reseller_id');
2258
-	  $reseller_pricing_result=$this->CI->db->get('reseller_pricing');
2259
-	  $account_info=(array)$reseller_pricing_result->first_row();
2260
-	  $account_name=$this->get_field_name_coma_new('first_name,last_name,number','accounts',$account_info['reseller_id']);
2258
+	  $reseller_pricing_result = $this->CI->db->get('reseller_pricing');
2259
+	  $account_info = (array)$reseller_pricing_result->first_row();
2260
+	  $account_name = $this->get_field_name_coma_new('first_name,last_name,number', 'accounts', $account_info['reseller_id']);
2261 2261
 	  return $account_name;     
2262 2262
 	}
2263 2263
 
2264
-	function get_status_new($select = "",$table = "",$status = "") {
2265
-	  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>";
2264
+	function get_status_new($select = "", $table = "", $status = "") {
2265
+	  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>";
2266 2266
 	}
2267 2267
     
2268 2268
 }
Please login to merge, or discard this patch.
Braces   +32 added lines, -29 removed lines patch added patch discarded remove patch
@@ -22,8 +22,9 @@  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 29
 /**
29 30
  * Dynamically build forms for display
@@ -113,8 +114,9 @@  discard block
 block discarded – undo
113 114
             $flag = false;
114 115
             $uname = $this->random_string($length);
115 116
             $uname = strtolower($uname);
116
-            if (isset($default))
117
-                $uname = $default.$uname;
117
+            if (isset($default)) {
118
+                            $uname = $default.$uname;
119
+            }
118 120
             if ( ! in_array($uname, $number)) {
119 121
                 $where = array($field => $uname);
120 122
                 $acc_result = $this->CI->db_model->getSelect('Count(id) as count', $tablename, $where);
@@ -243,8 +245,7 @@  discard block
 block discarded – undo
243 245
       $accountinfo = $this->CI->session->userdata('accountinfo');
244 246
       if ($did_info['accountid'] == 0 && $did_info['parent_id'] == 0) {
245 247
 	$status = 'Not in use';
246
-      }
247
-      elseif ($accountinfo['type'] != 1) {
248
+      } elseif ($accountinfo['type'] != 1) {
248 249
 	if ($did_info['accountid'] == 0 && $did_info['parent_id'] > 0) {
249 250
 	  $status = 'Purchase by Reseller';
250 251
 	}
@@ -274,8 +275,7 @@  discard block
 block discarded – undo
274 275
         $did_info = (array)$this->CI->db->get('dids')->first_row();
275 276
         if ($did_info['accountid'] > 0 && $did_info['parent_id'] == $accountinfo['id']) {
276 277
 	    $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>";
277
-	}
278
-        else if ($accountinfo['type'] != 1 && $did_info['parent_id'] != $accountinfo['id']) {
278
+	} else if ($accountinfo['type'] != 1 && $did_info['parent_id'] != $accountinfo['id']) {
279 279
 	    $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>";
280 280
         } else {
281 281
 	    $reseller_id = $accountinfo['type'] != 1 ? 0 : $accountinfo['id'];
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 			$rel = (isset($button_params->layout) && $button_params->layout != '')?"facebox_".$button_params->layout:"facebox";
871 871
 			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;';
872 872
             
873
-		}else if(strpos($link,'customer_edit') !== false){
873
+		} else if(strpos($link,'customer_edit') !== false){
874 874
 		return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
875
-		}else {
875
+		} else {
876 876
 			return '<a href="' . $link . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>&nbsp;';
877 877
 		}
878 878
 	}
@@ -913,14 +913,18 @@  discard block
 block discarded – undo
913 913
 		$data=  explode("/",$url);
914 914
 		$link = base_url() . $url . "" . $linkid;
915 915
 		foreach($data as $key=>$value){
916
-			if($value == 'price_delete')
917
-				$flag = '1';
918
-			if($value == 'trunk_remove')
919
-				$flag='2';
920
-			if($value == 'customer_delete' ||$value =='provider_delete')
921
-				$flag='3';
922
-			if($value == 'reseller_delete')
923
-				$flag='4';
916
+			if($value == 'price_delete') {
917
+							$flag = '1';
918
+			}
919
+			if($value == 'trunk_remove') {
920
+							$flag='2';
921
+			}
922
+			if($value == 'customer_delete' ||$value =='provider_delete') {
923
+							$flag='3';
924
+			}
925
+			if($value == 'reseller_delete') {
926
+							$flag='4';
927
+			}
924 928
 			}    
925 929
 			if($flag=='1'){
926 930
 				$where=array('pricelist_id'=>$linkid,'deleted !=' =>'1');
@@ -930,8 +934,7 @@  discard block
 block discarded – undo
930 934
 					if($rategroup_cnt > 0 || $customer_cnt > 0 ){
931 935
                         
932 936
 						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>';
933
-					}
934
-					else{
937
+					} else{
935 938
 						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>';
936 939
 					}
937 940
 			}
@@ -940,8 +943,7 @@  discard block
 block discarded – undo
940 943
 				$trunk_cnt=$this->get_field_count('id','outbound_routes',$where);
941 944
 				if($trunk_cnt > 0){
942 945
 					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>';
943
-				}
944
-				else{
946
+				} else{
945 947
 					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>';
946 948
 				}
947 949
 			}
@@ -2045,7 +2047,7 @@  discard block
 block discarded – undo
2045 2047
 
2046 2048
 		$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>';
2047 2049
 		$ACCOUNT_DESCRIPTION .= '</tr>';
2048
-		 }else{
2050
+		 } else{
2049 2051
 			$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']));
2050 2052
 			$cdrs_result = $cdrs_data->result_array();
2051 2053
 		if($cdrs_result[0]['count'] > 0 ){
@@ -2185,7 +2187,7 @@  discard block
 block discarded – undo
2185 2187
 		$download_path = $invoicedata['invoice_prefix'].$invoicedata['invoiceid'].".pdf";
2186 2188
        
2187 2189
 		$this->CI->html2pdf->Output($download_path,"D");        
2188
-	   }else{
2190
+	   } else{
2189 2191
 		$current_dir = getcwd()."/invoices/";
2190 2192
 		$dir_name = $accountdata["id"];
2191 2193
 		if(!is_dir($current_dir.$dir_name)){
@@ -2208,16 +2210,17 @@  discard block
 block discarded – undo
2208 2210
 		$select = "concat($cnt_str) as $select_params[2] ";
2209 2211
 		$drp_array = $this->CI->db_model->getSelect($select, $table, $where);
2210 2212
 		$drp_array = $drp_array->result();
2211
-		if (isset($drp_array[0]))
2212
-			return $drp_array[0]->$select_params[2];
2213
-	else
2214
-	   return 'Admin';
2213
+		if (isset($drp_array[0])) {
2214
+					return $drp_array[0]->$select_params[2];
2215
+		} else {
2216
+		   return 'Admin';
2217
+	}
2215 2218
 	}
2216 2219
     
2217 2220
 	function get_subreseller_info($parent_id){
2218 2221
 		if(!empty($parent_id)){
2219 2222
 	  $str=$parent_id.",";
2220
-		}else{
2223
+		} else{
2221 2224
 		  $str=null;
2222 2225
 		}
2223 2226
 		$query = "select id from accounts where reseller_id = '$parent_id' AND deleted =0 AND type=1";
@@ -2235,7 +2238,7 @@  discard block
 block discarded – undo
2235 2238
 	function get_parent_info($child_id,$parent_id){
2236 2239
 		if(!empty($child_id)){
2237 2240
 	  $str=$child_id.",";
2238
-		}else{
2241
+		} else{
2239 2242
 		  $str=null;
2240 2243
 		}
2241 2244
 		if($child_id > 0){
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/email_lib.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -88,29 +88,29 @@  discard block
 block discarded – undo
88 88
 		unset($query[0]['number']);
89 89
 		return $query[0];
90 90
 	}
91
-        return false;
92
-    }
91
+		return false;
92
+	}
93 93
 
94
-    /**
95
-     * @param string $detail_type
96
-     */
97
-    function get_info($id,$detail_type)
98
-    {
94
+	/**
95
+	 * @param string $detail_type
96
+	 */
97
+	function get_info($id,$detail_type)
98
+	{
99 99
 	$where = array('id' => $id);
100
-        $query = $this->CI->db_model->getSelect("*", $detail_type, $where);
101
-        $query = $query->result_array();
100
+		$query = $this->CI->db_model->getSelect("*", $detail_type, $where);
101
+		$query = $query->result_array();
102 102
 	if(isset($query[0]['accountid'])){
103 103
 		$query=$this->get_account_info($query [0]['accountid']);
104 104
 		return $query[0];
105 105
 	}
106 106
 	return false;
107
-    }
107
+	}
108 108
 
109
-    function get_admin_details()
110
-    {
109
+	function get_admin_details()
110
+	{
111 111
 	$where = array();
112
-        $query = $this->CI->db_model->getSelect("*", "invoice_conf", $where);
113
-        $query = $query->result();
112
+		$query = $this->CI->db_model->getSelect("*", "invoice_conf", $where);
113
+		$query = $query->result();
114 114
 	if(isset($query[0]->emailaddress) && $query[0]->emailaddress!=''){
115 115
 		$this->company_website=$query[0]->website;
116 116
 		$this->from=$query[0]->emailaddress;
@@ -165,33 +165,33 @@  discard block
 block discarded – undo
165 165
 		$this->subject = str_replace("#COMPANY_NAME#", $this->company_name, $this->subject);
166 166
 		switch ($template_type) {
167 167
 		  case 'email_add_user':
168
-		        $this->message = str_replace('#NUMBER#', $templateinfo['username'], $this->message);
169
-		        break;
168
+				$this->message = str_replace('#NUMBER#', $templateinfo['username'], $this->message);
169
+				break;
170 170
 		  case 'email_calling_card':
171
-		        $this->message = str_replace('#CARDNUMBER#', $templateinfo['cardnumber'], $this->message);
172
-		        break;
171
+				$this->message = str_replace('#CARDNUMBER#', $templateinfo['cardnumber'], $this->message);
172
+				break;
173 173
 		  case 'email_new_invoice';
174
-		        $this->message = str_replace('#AMOUNT#', $templateinfo['amount'], $this->message);
175
-		        $this->message = str_replace('#INVOICE_NUMBER#', $templateinfo['id'], $this->message);
176
-		        $this->subject = str_replace("#INVOICE_NUMBER#", $templateinfo['id'], $this->subject);
174
+				$this->message = str_replace('#AMOUNT#', $templateinfo['amount'], $this->message);
175
+				$this->message = str_replace('#INVOICE_NUMBER#', $templateinfo['id'], $this->message);
176
+				$this->subject = str_replace("#INVOICE_NUMBER#", $templateinfo['id'], $this->subject);
177 177
 			break;	
178 178
 		  case 'email_add_did';
179
-		        $this->message = str_replace('#NUNBER#', $templateinfo['number'], $this->message);
180
-		        $this->subject = str_replace("#NUNBER#", $templateinfo['number'], $this->subject);
179
+				$this->message = str_replace('#NUNBER#', $templateinfo['number'], $this->message);
180
+				$this->subject = str_replace("#NUNBER#", $templateinfo['number'], $this->subject);
181 181
 			break;	
182 182
 		  case 'email_remove_did';
183
-		        $this->message = str_replace('#NUNBER#', $templateinfo['number'], $this->message);
184
-		        $this->subject = str_replace("#NUNBER#", $templateinfo['number'], $this->subject);
183
+				$this->message = str_replace('#NUNBER#', $templateinfo['number'], $this->message);
184
+				$this->subject = str_replace("#NUNBER#", $templateinfo['number'], $this->subject);
185 185
 			break;	
186 186
 		}
187 187
 	}
188
-    }
188
+	}
189 189
 
190
-    /**
191
-     * @param string $attachment
192
-     */
193
-    function mail_history($attachment)
194
-    {
190
+	/**
191
+	 * @param string $attachment
192
+	 */
193
+	function mail_history($attachment)
194
+	{
195 195
 		$send_mail_details = array('from'=>$this->from,
196 196
 			   'to'=>$this->to,
197 197
 			   'subject'=>$this->subject,
Please login to merge, or discard this 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,14 +77,14 @@  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
 	}
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * @param string $detail_type
96 96
      */
97
-    function get_info($id,$detail_type)
97
+    function get_info($id, $detail_type)
98 98
     {
99 99
 	$where = array('id' => $id);
100 100
         $query = $this->CI->db_model->getSelect("*", $detail_type, $where);
101 101
         $query = $query->result_array();
102
-	if(isset($query[0]['accountid'])){
103
-		$query=$this->get_account_info($query [0]['accountid']);
102
+	if (isset($query[0]['accountid'])) {
103
+		$query = $this->get_account_info($query [0]['accountid']);
104 104
 		return $query[0];
105 105
 	}
106 106
 	return false;
@@ -111,47 +111,47 @@  discard block
 block discarded – undo
111 111
 	$where = array();
112 112
         $query = $this->CI->db_model->getSelect("*", "invoice_conf", $where);
113 113
         $query = $query->result();
114
-	if(isset($query[0]->emailaddress) && $query[0]->emailaddress!=''){
115
-		$this->company_website=$query[0]->website;
116
-		$this->from=$query[0]->emailaddress;
117
-		$this->company_name=$query[0]->company_name;
114
+	if (isset($query[0]->emailaddress) && $query[0]->emailaddress != '') {
115
+		$this->company_website = $query[0]->website;
116
+		$this->from = $query[0]->emailaddress;
117
+		$this->company_name = $query[0]->company_name;
118 118
 		return true;
119 119
 	}
120 120
 	return false;
121 121
 	}
122 122
 
123
-	function build_template($template_type,$detail,$detail_type='') {
124
-	if(!is_array($template_type))
123
+	function build_template($template_type, $detail, $detail_type = '') {
124
+	if ( ! is_array($template_type))
125 125
 		$this->get_template($template_type);
126
-	else{
127
-		$this->message=$template_type['message'];
128
-		$this->subject=$template_type['subject'];
129
-		$template_type='';
126
+	else {
127
+		$this->message = $template_type['message'];
128
+		$this->subject = $template_type['subject'];
129
+		$template_type = '';
130 130
 	}
131
-	if(is_array($detail))
131
+	if (is_array($detail))
132 132
 	{
133
-		$templateinfo=$detail;
134
-		if(isset($detail['email'])){
135
-			$this->to=$detail['email'];
133
+		$templateinfo = $detail;
134
+		if (isset($detail['email'])) {
135
+			$this->to = $detail['email'];
136 136
 		}
137 137
 /*****
138 138
 ASTPP  3.0 
139 139
 Email test
140 140
 ****/
141
-		if(isset($templateinfo['number'])){	
142
-			$templateinfo['username']=$templateinfo['number'];
141
+		if (isset($templateinfo['number'])) {	
142
+			$templateinfo['username'] = $templateinfo['number'];
143 143
 		}
144 144
 
145 145
 /*************/
146
-		$this->account_id=$templateinfo['accountid'];
146
+		$this->account_id = $templateinfo['accountid'];
147 147
 		unset($templateinfo['number']);
148
-	} else if(!is_array($detail) && $detail_type=='') {
149
-			$templateinfo=$this->get_account_info($detail);
148
+	} else if ( ! is_array($detail) && $detail_type == '') {
149
+			$templateinfo = $this->get_account_info($detail);
150 150
 	} else {
151
-			$templateinfo=$this->get_info($detail,$detail_type);
151
+			$templateinfo = $this->get_info($detail, $detail_type);
152 152
 	}
153 153
 
154
-	if($this->get_admin_details() && is_array($templateinfo) && isset($templateinfo['first_name']) && $templateinfo['first_name']!=''){
154
+	if ($this->get_admin_details() && is_array($templateinfo) && isset($templateinfo['first_name']) && $templateinfo['first_name'] != '') {
155 155
 		$this->message = html_entity_decode($this->message);
156 156
 		$this->message = str_replace("#COMPANY_EMAIL#", $this->from, $this->message);
157 157
 		$this->message = str_replace("#COMPANY_NAME#", $this->company_name, $this->message);
@@ -200,33 +200,33 @@  discard block
 block discarded – undo
200 200
 			   'status'=>'1',
201 201
 			   'attachment'=>$attachment
202 202
 			  );
203
-		$this->CI->db->insert('mail_details',$send_mail_details);
203
+		$this->CI->db->insert('mail_details', $send_mail_details);
204 204
 		return $this->CI->db->insert_id();
205 205
 	}
206 206
 	function update_mail_history($id)
207 207
 	{
208 208
 		$this->CI->db->where(array('id' => $id));
209 209
 		$send_mail_details = array('status'=>'0');
210
-		$this->CI->db->update('mail_details',$send_mail_details);
210
+		$this->CI->db->update('mail_details', $send_mail_details);
211 211
 	}
212 212
 	function set_email_paramenters($details)
213 213
 	{
214
-		if(!is_array($details)){
214
+		if ( ! is_array($details)) {
215 215
 			$this->get_admin_details();
216 216
 			$where = array('id'=>$details);
217 217
 			$query = $this->CI->db_model->getSelect("*", "mail_details", $where);
218 218
 			$query = $query->result_array();
219
-			$details=$query[0];
219
+			$details = $query[0];
220 220
 		}
221
-		$this->message=$details['body'];
222
-		$this->from=$details['from'];
223
-		$this->to=$details['to'];
224
-		$this->subject=$details['subject'];
225
-		$this->account_id=$details['accountid'];
221
+		$this->message = $details['body'];
222
+		$this->from = $details['from'];
223
+		$this->to = $details['to'];
224
+		$this->subject = $details['subject'];
225
+		$this->account_id = $details['accountid'];
226 226
 	}
227 227
 	function get_smtp_details()
228 228
 	{
229
-	if($this->smtp_port=='' || $this->smtp_host=='' || $this->smtp_user=='' || $this->smtp_pass=='')exit;
229
+	if ($this->smtp_port == '' || $this->smtp_host == '' || $this->smtp_user == '' || $this->smtp_pass == '')exit;
230 230
 		$config['protocol'] = "smtp";
231 231
 		$config['smtp_host'] = $this->smtp_host;
232 232
 		$config['smtp_port'] = $this->smtp_port;
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
 		$this->CI->email->initialize($config);
239 239
 	}
240 240
 
241
-	function send_email($template_type,$details,$detail_type='',$attachment='',$resend=0,$mass_mail=0,$brodcast=0) {
241
+	function send_email($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) {
242 242
 	$this->get_email_settings();
243
-	if(!$this->email){
244
-		if(!$resend){
245
-			$this->build_template($template_type,$details,$detail_type);
246
-		}else{
243
+	if ( ! $this->email) {
244
+		if ( ! $resend) {
245
+			$this->build_template($template_type, $details, $detail_type);
246
+		} else {
247 247
 			$this->set_email_paramenters($details);
248 248
 		}
249 249
 
250
-		if(!$brodcast)
251
-				$history_id=$this->mail_history($attachment);
250
+		if ( ! $brodcast)
251
+				$history_id = $this->mail_history($attachment);
252 252
 		else	
253
-			$history_id=$details['history_id'];
254
-		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
255
-			if(!$this->smtp){
253
+			$history_id = $details['history_id'];
254
+		if (isset($this->from) && $this->from != '' && isset($this->to) && $this->to != '' && ! $mass_mail) {
255
+			if ( ! $this->smtp) {
256 256
 				$this->get_smtp_details();
257 257
 			}			
258 258
 			$this->CI->email->from($this->from, $this->company_name);
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 			eval("\$message = \"".$this->message."\";");
263 263
 			$this->CI->email->message($this->message);
264 264
 
265
-			if($attachment!="")
265
+			if ($attachment != "")
266 266
 			{
267
-					$attac_exp=explode(",",$attachment);
268
-			   	  	foreach($attac_exp as $key=>$value){
269
-			   		if($value != ''){
267
+					$attac_exp = explode(",", $attachment);
268
+			   	  	foreach ($attac_exp as $key=>$value) {
269
+			   		if ($value != '') {
270 270
 				   	$this->CI->email->attach(getcwd()."/attachments/".$value);       	  	
271 271
 				   	}
272 272
 				}
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
 ASTPP  3.0 
282 282
 Add For Signup Module
283 283
 **/
284
-	function send_mail($template_type,$details,$detail_type='',$attachment='',$resend=0,$mass_mail=0,$brodcast=0) {
284
+	function send_mail($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) {
285 285
 	$this->get_email_settings();
286
-	if(!$this->email){
286
+	if ( ! $this->email) {
287 287
 		
288
-		if(!$resend){
289
-			$this->build_template($template_type,$details,$detail_type);
290
-		}else{
288
+		if ( ! $resend) {
289
+			$this->build_template($template_type, $details, $detail_type);
290
+		} else {
291 291
 			$this->set_email_paramenters($details);
292 292
 		}
293 293
 
294
-		if(!$brodcast)
295
-				$history_id=$this->mail_history($attachment);
294
+		if ( ! $brodcast)
295
+				$history_id = $this->mail_history($attachment);
296 296
 		else	
297
-			$history_id=$details['history_id'];
298
-		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
299
-			if(!$this->smtp){
297
+			$history_id = $details['history_id'];
298
+		if (isset($this->from) && $this->from != '' && isset($this->to) && $this->to != '' && ! $mass_mail) {
299
+			if ( ! $this->smtp) {
300 300
 				$this->get_smtp_details();
301 301
 			}			
302 302
 			$this->CI->email->from($this->from, $this->company_name);
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  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 28
 /**
28 29
  * Dynamically build forms for display
@@ -121,9 +122,9 @@  discard block
 block discarded – undo
121 122
 	}
122 123
 
123 124
 	function build_template($template_type,$detail,$detail_type='') {
124
-	if(!is_array($template_type))
125
-		$this->get_template($template_type);
126
-	else{
125
+	if(!is_array($template_type)) {
126
+			$this->get_template($template_type);
127
+	} else{
127 128
 		$this->message=$template_type['message'];
128 129
 		$this->subject=$template_type['subject'];
129 130
 		$template_type='';
@@ -226,7 +227,9 @@  discard block
 block discarded – undo
226 227
 	}
227 228
 	function get_smtp_details()
228 229
 	{
229
-	if($this->smtp_port=='' || $this->smtp_host=='' || $this->smtp_user=='' || $this->smtp_pass=='')exit;
230
+	if($this->smtp_port=='' || $this->smtp_host=='' || $this->smtp_user=='' || $this->smtp_pass=='') {
231
+		exit;
232
+	}
230 233
 		$config['protocol'] = "smtp";
231 234
 		$config['smtp_host'] = $this->smtp_host;
232 235
 		$config['smtp_port'] = $this->smtp_port;
@@ -243,14 +246,15 @@  discard block
 block discarded – undo
243 246
 	if(!$this->email){
244 247
 		if(!$resend){
245 248
 			$this->build_template($template_type,$details,$detail_type);
246
-		}else{
249
+		} else{
247 250
 			$this->set_email_paramenters($details);
248 251
 		}
249 252
 
250
-		if(!$brodcast)
251
-				$history_id=$this->mail_history($attachment);
252
-		else	
253
-			$history_id=$details['history_id'];
253
+		if(!$brodcast) {
254
+						$history_id=$this->mail_history($attachment);
255
+		} else {
256
+					$history_id=$details['history_id'];
257
+		}
254 258
 		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
255 259
 			if(!$this->smtp){
256 260
 				$this->get_smtp_details();
@@ -287,14 +291,15 @@  discard block
 block discarded – undo
287 291
 		
288 292
 		if(!$resend){
289 293
 			$this->build_template($template_type,$details,$detail_type);
290
-		}else{
294
+		} else{
291 295
 			$this->set_email_paramenters($details);
292 296
 		}
293 297
 
294
-		if(!$brodcast)
295
-				$history_id=$this->mail_history($attachment);
296
-		else	
297
-			$history_id=$details['history_id'];
298
+		if(!$brodcast) {
299
+						$history_id=$this->mail_history($attachment);
300
+		} else {
301
+					$history_id=$details['history_id'];
302
+		}
298 303
 		if(isset($this->from) && $this->from!='' && isset($this->to) && $this->to!='' && !$mass_mail){
299 304
 			if(!$this->smtp){
300 305
 				$this->get_smtp_details();
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/astpp/permission.php 2 patches
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.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@
 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 27
 class Permission {
27 28
 	function __construct($library_name = '') {
Please login to merge, or discard this patch.
application/libraries/html2pdf/_tcpdf_5.0.002/fonts/utils/makefont.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -533,9 +533,9 @@
 block discarded – undo
533 533
  * @param string $file
534 534
  * @param string $s
535 535
  */
536
-function SaveToFile($file, $s, $mode='t') {
536
+function SaveToFile($file, $s, $mode = 't') {
537 537
 	$f = fopen($file, 'w'.$mode);
538
-	if(!$f) {
538
+	if ( ! $f) {
539 539
 		die('Can\'t write to file '.$file);
540 540
 	}
541 541
 	fwrite($f, $s, strlen($s));
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/html2pdf/_class/locale.class.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	static public function load($code)
39 39
 	{
40
-		if (self::$_directory===null) {
40
+		if (self::$_directory === null) {
41 41
 			self::$_directory = dirname(dirname(__FILE__)).'/locale/';
42 42
 		}
43 43
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$code = strtolower($code);
46 46
 
47 47
 		// must be [a-z-0-9]
48
-		if (!preg_match('/^([a-z0-9]+)$/isU', $code)) {
48
+		if ( ! preg_match('/^([a-z0-9]+)$/isU', $code)) {
49 49
 			throw new HTML2PDF_exception(0, 'invalid language code ['.self::$_code.']');
50 50
 		}
51 51
 
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 		$file = self::$_directory.self::$_code.'.csv';
57 57
 
58 58
 		// the file must exist
59
-		if (!is_file($file)) {
59
+		if ( ! is_file($file)) {
60 60
 			throw new HTML2PDF_exception(0, 'language code ['.self::$_code.'] unknown. You can create the translation file ['.$file.'] and send it to the webmaster of html2pdf in order to integrate it into a future release');
61 61
 		}
62 62
 
63 63
 		// load the file
64 64
 		self::$_list = array();
65 65
 		$handle = fopen($file, 'r');
66
-		while (!feof($handle)) {
66
+		while ( ! feof($handle)) {
67 67
 			$line = fgetcsv($handle);
68
-			if (count($line)!=2) continue;
68
+			if (count($line) != 2) continue;
69 69
 			self::$_list[trim($line[0])] = trim($line[1]);
70 70
 		}
71 71
 		fclose($handle);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @param  string $key
90 90
 	 * @return string
91 91
 	 */
92
-	static public function get($key, $default='######')
92
+	static public function get($key, $default = '######')
93 93
 	{
94 94
 		return (isset(self::$_list[$key]) ? self::$_list[$key] : $default);
95 95
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@
 block discarded – undo
65 65
 		$handle = fopen($file, 'r');
66 66
 		while (!feof($handle)) {
67 67
 			$line = fgetcsv($handle);
68
-			if (count($line)!=2) continue;
68
+			if (count($line)!=2) {
69
+				continue;
70
+			}
69 71
 			self::$_list[trim($line[0])] = trim($line[1]);
70 72
 		}
71 73
 		fclose($handle);
Please login to merge, or discard this patch.
astpp/application/libraries/html2pdf/_class/exception.class.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	final public function __construct($err = 0, $other = null, $html = '')
28 28
 	{
29 29
 		// read the error
30
-		switch($err)
30
+		switch ($err)
31 31
 		{
32 32
 			case 1: // Unsupported tag
33 33
 				$msg = (HTML2PDF_locale::get('err01'));
@@ -89,19 +89,19 @@  discard block
 block discarded – undo
89 89
 
90 90
 		// create the HTML message
91 91
 		$this->_messageHtml = '<span style="color: #AA0000; font-weight: bold;">'.HTML2PDF_locale::get('txt01', 'error: ').$err.'</span><br>';
92
-		$this->_messageHtml.= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>';
93
-		$this->_messageHtml.= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>';
94
-		$this->_messageHtml.= '<br>';
95
-		$this->_messageHtml.= $msg;
92
+		$this->_messageHtml .= HTML2PDF_locale::get('txt02', 'file:').' '.$this->file.'<br>';
93
+		$this->_messageHtml .= HTML2PDF_locale::get('txt03', 'line:').' '.$this->line.'<br>';
94
+		$this->_messageHtml .= '<br>';
95
+		$this->_messageHtml .= $msg;
96 96
 
97 97
 		// create the text message
98 98
 		$msg = HTML2PDF_locale::get('txt01', 'error: ').$err.' : '.strip_tags($msg);
99 99
 
100 100
 		// add the optionnal html content
101 101
 		if ($html) {
102
-			$this->_messageHtml.= "<br><br>HTML : ...".trim(htmlentities($html)).'...';
102
+			$this->_messageHtml .= "<br><br>HTML : ...".trim(htmlentities($html)).'...';
103 103
 			$this->_html = $html;
104
-			$msg.= ' HTML : ...'.trim($html).'...';
104
+			$msg .= ' HTML : ...'.trim($html).'...';
105 105
 		}
106 106
 
107 107
 		// save the other informations
Please login to merge, or discard this patch.