Passed
Push — v3.0 ( 7b2427...598da8 )
by Samir
23:40 queued 09:48
created
web_interface/astpp/application/controllers/feedback.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -28,59 +28,59 @@  discard block
 block discarded – undo
28 28
 		parent::__construct();
29 29
 	}
30 30
 	
31
-	function index(){
31
+	function index() {
32 32
 		$data['account_info'] = $this->session->userdata['accountinfo'];
33 33
 		$data['username'] = $this->session->userdata('user_name');
34 34
 		$data['page_title'] = "Feedback";
35
-		$this->load->view('view_feedback',$data);
35
+		$this->load->view('view_feedback', $data);
36 36
 	}
37
-	function customer_feedback_result($flag=FALSE){
38
-		if($flag){
37
+	function customer_feedback_result($flag = FALSE) {
38
+		if ($flag) {
39 39
 			$account_info = array();
40
-			$this->db->where("accountid","1");
40
+			$this->db->where("accountid", "1");
41 41
 			$res = $this->db->get('invoice_conf');
42
-			if($res->num_rows > 0){
42
+			if ($res->num_rows > 0) {
43 43
 				$masterdata = $res->result_array();
44 44
 				$account_info = $masterdata['0'];
45 45
 
46
-				$company_name=$account_info['company_name'];
47
-				$address=$account_info['address'];
48
-				$city=$account_info['city'];
49
-				$province=$account_info['province'];
50
-				$country=$account_info['country'];
51
-				$zipcode=$account_info['zipcode'];
52
-				$telephone=$account_info['telephone'];
53
-				$fax=$account_info['fax'];
54
-				$emailaddress=$account_info['emailaddress'];
55
-				$website=$account_info['website'];
46
+				$company_name = $account_info['company_name'];
47
+				$address = $account_info['address'];
48
+				$city = $account_info['city'];
49
+				$province = $account_info['province'];
50
+				$country = $account_info['country'];
51
+				$zipcode = $account_info['zipcode'];
52
+				$telephone = $account_info['telephone'];
53
+				$fax = $account_info['fax'];
54
+				$emailaddress = $account_info['emailaddress'];
55
+				$website = $account_info['website'];
56 56
 
57
-				$data=array("name"=>"Admin","company_name"=>$company_name,"address"=>$address,"city"=>$city,"province"=>$province,"country"=>$country,"zipcode"=>$zipcode,"telephone"=>$telephone,"fax"=>$fax,"emailaddress"=>$emailaddress,"website"=>$website,"serverip"=>$_SERVER['SERVER_NAME'],"FLAG"=>"TRUE");				
57
+				$data = array("name"=>"Admin", "company_name"=>$company_name, "address"=>$address, "city"=>$city, "province"=>$province, "country"=>$country, "zipcode"=>$zipcode, "telephone"=>$telephone, "fax"=>$fax, "emailaddress"=>$emailaddress, "website"=>$website, "serverip"=>$_SERVER['SERVER_NAME'], "FLAG"=>"TRUE");				
58 58
 			}
59
-		} else{
59
+		} else {
60 60
 			$account_info = array();
61
-			$this->db->where("type","-1");
61
+			$this->db->where("type", "-1");
62 62
 			$res = $this->db->get('accounts');
63
-			if($res->num_rows > 0){
63
+			if ($res->num_rows > 0) {
64 64
 				$masterdata = $res->result_array();
65 65
 				$account_info = $masterdata['0'];
66 66
 
67
-			$name=$_REQUEST['name']="Admin";
68
-			$email=$_REQUEST['email']=$account_info['email'];
69
-			$feedback=$_REQUEST['feedback'];
70
-			$first_name=$account_info['first_name'];
71
-			$last_name=$account_info['last_name'];
72
-			$city=$account_info['city'];
73
-			$telephone_1=$account_info['telephone_1'];
74
-			$account_email=$account_info['email'];
75
-			$company_name=$account_info['company_name'];
76
-			$address_1=$account_info['address_1'];
77
-			$address_2=$account_info['address_2'];
78
-			$telephone_2=$account_info['telephone_2'];
79
-			$province=$account_info['province'];
67
+			$name = $_REQUEST['name'] = "Admin";
68
+			$email = $_REQUEST['email'] = $account_info['email'];
69
+			$feedback = $_REQUEST['feedback'];
70
+			$first_name = $account_info['first_name'];
71
+			$last_name = $account_info['last_name'];
72
+			$city = $account_info['city'];
73
+			$telephone_1 = $account_info['telephone_1'];
74
+			$account_email = $account_info['email'];
75
+			$company_name = $account_info['company_name'];
76
+			$address_1 = $account_info['address_1'];
77
+			$address_2 = $account_info['address_2'];
78
+			$telephone_2 = $account_info['telephone_2'];
79
+			$province = $account_info['province'];
80 80
 
81
-			$data=array("name"=>$name,"email"=>$email,"feedback"=>$feedback,"first_name"=>$first_name,"last_name"=>$last_name,"city"=>$city,"telephone_1"=>$telephone_1,"account_email"=>$account_email,"company_name"=>$company_name,"address_1"=>$address_1,"address_2"=>$address_2,"telephone_2"=>$telephone_2,"province"=>$province,"serverip"=>$_SERVER['SERVER_ADDR'],"FLAG"=>"FALSE");
81
+			$data = array("name"=>$name, "email"=>$email, "feedback"=>$feedback, "first_name"=>$first_name, "last_name"=>$last_name, "city"=>$city, "telephone_1"=>$telephone_1, "account_email"=>$account_email, "company_name"=>$company_name, "address_1"=>$address_1, "address_2"=>$address_2, "telephone_2"=>$telephone_2, "province"=>$province, "serverip"=>$_SERVER['SERVER_ADDR'], "FLAG"=>"FALSE");
82 82
 
83
-				$data_new= json_encode($data);
83
+				$data_new = json_encode($data);
84 84
 			}
85 85
 		}
86 86
 		$ch = curl_init();
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
97 97
 
98 98
 		$response = curl_exec($ch);
99
-		if(!$flag)
100
-		 redirect(base_url() . 'feedback/thanks');
99
+		if ( ! $flag)
100
+		 redirect(base_url().'feedback/thanks');
101 101
 	    
102 102
 
103 103
 	}
104
-	function thanks(){
104
+	function thanks() {
105 105
 			$this->load->view('view_feedback_response');
106 106
 	}	
107 107
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@
 block discarded – undo
96 96
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
97 97
 
98 98
 		$response = curl_exec($ch);
99
-		if(!$flag)
100
-		 redirect(base_url() . 'feedback/thanks');
99
+		if(!$flag) {
100
+				 redirect(base_url() . 'feedback/thanks');
101
+		}
101 102
 	    
102 103
 
103 104
 	}
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/currencyupdate.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -21,48 +21,48 @@  discard block
 block discarded – undo
21 21
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 22
 ###############################################################################
23 23
 class Currencyupdate extends CI_Controller {
24
-    function __construct()
25
-    {
26
-        parent::__construct();
27
-     //   if(!defined( 'CRON' ) )
28
-       //   exit();
29
-        $this->load->model("db_model");
30
-        $this->load->library("astpp/common");
31
-    }
32
-    function update_currency() {
33
-        $where = array("currency <>"=> Common_model::$global_config['system_config']['base_currency']);
34
-        $query = $this->db_model->getSelect("*", "currency", $where);
24
+	function __construct()
25
+	{
26
+		parent::__construct();
27
+	 //   if(!defined( 'CRON' ) )
28
+	   //   exit();
29
+		$this->load->model("db_model");
30
+		$this->load->library("astpp/common");
31
+	}
32
+	function update_currency() {
33
+		$where = array("currency <>"=> Common_model::$global_config['system_config']['base_currency']);
34
+		$query = $this->db_model->getSelect("*", "currency", $where);
35 35
 
36
-        if ($query->num_rows > 0) {
37
-            $currency_data = $query->result_array();
38
-    		$url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=";
39
-	    	foreach ($currency_data as $currency_value) {
40
-	    	    $url .= Common_model::$global_config['system_config']['base_currency'].$currency_value['currency'].'=X+';
41
-	    	}
42
-	    	$url .= '&f=l1';
36
+		if ($query->num_rows > 0) {
37
+			$currency_data = $query->result_array();
38
+			$url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=";
39
+			foreach ($currency_data as $currency_value) {
40
+				$url .= Common_model::$global_config['system_config']['base_currency'].$currency_value['currency'].'=X+';
41
+			}
42
+			$url .= '&f=l1';
43 43
 
44
-	    	$sql = '';
45
-	    	$response = $this->curl_response($url);
46
-	    	$content_data = explode(' ', $response);
44
+			$sql = '';
45
+			$response = $this->curl_response($url);
46
+			$content_data = explode(' ', $response);
47 47
 
48
-	    	foreach ($content_data as $content_data1) {
49
-	    	   $currency_arr = explode("\n", $content_data1);
50
-	    	    foreach ($currency_arr as $final_val)
51
-	    	    {
52
-	    	        $currency_final = array();
53
-	    		    $currency_final = explode(',', $final_val);
54
-	    		    if (isset($currency_final[1]) && $currency_final[1] != "" && $currency_final[0] != '' && $currency_final[1] != 'N/A') {
55
-			      $sql = "UPDATE currency SET currencyRate = ".$currency_final[1]." WHERE currency = '".substr($currency_final[0], 4, 3)."'";
56
-			      $this->db->query($sql);
57
-	    		    }
58
-	    	    }
59
-	    	}
60
-	    	$sql = "UPDATE currency SET currencyRate = '1' WHERE currency = '".Common_model::$global_config['system_config']['base_currency']."'";
61
-                $this->db->query($sql);
62
-      }
63
-	      $this->session->set_flashdata("astpp_errormsg", "Currency exchange rates successfully updated.");
64
-	      redirect(base_url()."/systems/currency_list/");
65
-	      exit;
48
+			foreach ($content_data as $content_data1) {
49
+			   $currency_arr = explode("\n", $content_data1);
50
+				foreach ($currency_arr as $final_val)
51
+				{
52
+					$currency_final = array();
53
+					$currency_final = explode(',', $final_val);
54
+					if (isset($currency_final[1]) && $currency_final[1] != "" && $currency_final[0] != '' && $currency_final[1] != 'N/A') {
55
+				  $sql = "UPDATE currency SET currencyRate = ".$currency_final[1]." WHERE currency = '".substr($currency_final[0], 4, 3)."'";
56
+				  $this->db->query($sql);
57
+					}
58
+				}
59
+			}
60
+			$sql = "UPDATE currency SET currencyRate = '1' WHERE currency = '".Common_model::$global_config['system_config']['base_currency']."'";
61
+				$this->db->query($sql);
62
+	  }
63
+		  $this->session->set_flashdata("astpp_errormsg", "Currency exchange rates successfully updated.");
64
+		  redirect(base_url()."/systems/currency_list/");
65
+		  exit;
66 66
 	}
67 67
 
68 68
 	/**
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	function curl_response($url)
72 72
 	{
73
-		    $ch = curl_init(); // Initialising cURL
74
-		    curl_setopt($ch, CURLOPT_URL, $url);
75
-		    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
76
-		    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
77
-		    curl_setopt($ch, CURLOPT_ENCODING, "");
78
-		    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
79
-		    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
80
-		    curl_close($ch); // Closing cURL
81
-		    return $data;
73
+			$ch = curl_init(); // Initialising cURL
74
+			curl_setopt($ch, CURLOPT_URL, $url);
75
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
76
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
77
+			curl_setopt($ch, CURLOPT_ENCODING, "");
78
+			curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
79
+			$data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
80
+			curl_close($ch); // Closing cURL
81
+			return $data;
82 82
 	}
83 83
 }
84 84
 ?>
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/updateBalance.php 2 patches
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -24,271 +24,271 @@
 block discarded – undo
24 24
 
25 25
 class UpdateBalance extends MX_Controller {
26 26
 
27
-    public $account_arr = array();
28
-    public $currentdate = '';
27
+	public $account_arr = array();
28
+	public $currentdate = '';
29 29
 
30
-    function __construct() {
31
-        parent::__construct();
32
-        $this->load->model("db_model");
33
-        $this->load->model("common_model");
34
-        $this->load->library("astpp/common");
35
-        $this->currentdate = gmdate('Y-m-d H:i:s');
36
-    }
30
+	function __construct() {
31
+		parent::__construct();
32
+		$this->load->model("db_model");
33
+		$this->load->model("common_model");
34
+		$this->load->library("astpp/common");
35
+		$this->currentdate = gmdate('Y-m-d H:i:s');
36
+	}
37 37
 
38
-    function GetUpdateBalance() {
39
-        $accounts_data = $this->get_table_data("*", "accounts", array("status" => "0", "deleted" => "0"));
40
-        foreach ($accounts_data as $account_val) {
41
-            $this->process_subscriptions($account_val, gmdate("Y-m-d H:i:s"), gmdate("Y-m-d H:i:s"));
42
-            $this->process_DID_charges($account_val, gmdate("Y-m-d H:i:s"), gmdate("Y-m-d H:i:s"));
43
-        }
44
-    }
38
+	function GetUpdateBalance() {
39
+		$accounts_data = $this->get_table_data("*", "accounts", array("status" => "0", "deleted" => "0"));
40
+		foreach ($accounts_data as $account_val) {
41
+			$this->process_subscriptions($account_val, gmdate("Y-m-d H:i:s"), gmdate("Y-m-d H:i:s"));
42
+			$this->process_DID_charges($account_val, gmdate("Y-m-d H:i:s"), gmdate("Y-m-d H:i:s"));
43
+		}
44
+	}
45 45
 
46
-    function process_subscriptions($accountinfo, $startdate, $enddate, $Manualflg = false) {
46
+	function process_subscriptions($accountinfo, $startdate, $enddate, $Manualflg = false) {
47 47
 //        Defined Original Sweep it for calculation start date for first time.
48
-        $accountinfo['original_sweep_id'] = $accountinfo['sweep_id'];
49
-        $invoiceid = 0;
48
+		$accountinfo['original_sweep_id'] = $accountinfo['sweep_id'];
49
+		$invoiceid = 0;
50 50
         
51
-        // Check Charge is applied that is for first time or already calculated before
51
+		// Check Charge is applied that is for first time or already calculated before
52 52
 
53
-        $where = "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='".gmdate("Y-m-d H:i:s")."')";
54
-        $this->db->where('accountid', $accountinfo['id']);
55
-        $this->db->where($where);
56
-        $this->db->select('*');
57
-        $account_charges = $this->db->get('charge_to_account');
58
-        if ($account_charges->num_rows() > 0) {
59
-            $accountchargs = $account_charges->result_array();
53
+		$where = "(charge_upto ='0000-00-00 00:00:00' OR charge_upto <='".gmdate("Y-m-d H:i:s")."')";
54
+		$this->db->where('accountid', $accountinfo['id']);
55
+		$this->db->where($where);
56
+		$this->db->select('*');
57
+		$account_charges = $this->db->get('charge_to_account');
58
+		if ($account_charges->num_rows() > 0) {
59
+			$accountchargs = $account_charges->result_array();
60 60
 
61
-            foreach ($accountchargs as $accharges) {
62
-                //Get information from database of active charges.
63
-                $charge_data = $this->get_table_data("*", "charges", array("id" => $accharges['charge_id'], "status" => "0"));
64
-                if ($charge_data && ! empty($charge_data)) {
65
-                    $charge_data = $charge_data[0];
66
-                    //Get Start Date of Charge
67
-                    $charge_upto = ($accharges["charge_upto"] != "0000-00-00 00:00:00" && $accharges["charge_upto"] != "") ?
68
-                            date("Y-m-d H:i:s", strtotime("+1 Second", strtotime($accharges["charge_upto"]))) : $accharges["assign_date"];
69
-                   if ($accountinfo['original_sweep_id'] == 2 && $charge_data['pro_rate'] == 0 && $charge_data['sweep_id'] == 2 && ($accountinfo['invoice_day'] < gmdate("d", strtotime($accharges['assign_date'])))) {
70
-                      $charge_upto = date("Y-m-".$accountinfo['invoice_day']." H:i:s", strtotime($accharges["assign_date"]));
71
-                   }
72
-                    //Overwrite Billing scehdule of customer assign proper charge
73
-                    if ($accountinfo['sweep_id'] != $charge_data['sweep_id']) {
74
-                        $accountinfo['sweep_id'] = $charge_data['sweep_id'];
75
-                    }
76
-                    //IF its already assigned before invoice start date then no need to applied same charge one more time
77
-                    if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime($charge_upto) < strtotime($enddate)) {
78
-                        $fromdate = gmdate("Y-m-d H:i:s", strtotime($charge_upto));
79
-                        if ($Manualflg) {
80
-                            $todate = gmdate("Y-m-d H:i:s", strtotime($enddate));
81
-                        } else {
82
-                            $todate = gmdate("Y-m-d H:i:s", strtotime($charge_upto));
83
-                        }
84
-                        /*
61
+			foreach ($accountchargs as $accharges) {
62
+				//Get information from database of active charges.
63
+				$charge_data = $this->get_table_data("*", "charges", array("id" => $accharges['charge_id'], "status" => "0"));
64
+				if ($charge_data && ! empty($charge_data)) {
65
+					$charge_data = $charge_data[0];
66
+					//Get Start Date of Charge
67
+					$charge_upto = ($accharges["charge_upto"] != "0000-00-00 00:00:00" && $accharges["charge_upto"] != "") ?
68
+							date("Y-m-d H:i:s", strtotime("+1 Second", strtotime($accharges["charge_upto"]))) : $accharges["assign_date"];
69
+				   if ($accountinfo['original_sweep_id'] == 2 && $charge_data['pro_rate'] == 0 && $charge_data['sweep_id'] == 2 && ($accountinfo['invoice_day'] < gmdate("d", strtotime($accharges['assign_date'])))) {
70
+					  $charge_upto = date("Y-m-".$accountinfo['invoice_day']." H:i:s", strtotime($accharges["assign_date"]));
71
+				   }
72
+					//Overwrite Billing scehdule of customer assign proper charge
73
+					if ($accountinfo['sweep_id'] != $charge_data['sweep_id']) {
74
+						$accountinfo['sweep_id'] = $charge_data['sweep_id'];
75
+					}
76
+					//IF its already assigned before invoice start date then no need to applied same charge one more time
77
+					if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime($charge_upto) < strtotime($enddate)) {
78
+						$fromdate = gmdate("Y-m-d H:i:s", strtotime($charge_upto));
79
+						if ($Manualflg) {
80
+							$todate = gmdate("Y-m-d H:i:s", strtotime($enddate));
81
+						} else {
82
+							$todate = gmdate("Y-m-d H:i:s", strtotime($charge_upto));
83
+						}
84
+						/*
85 85
                          * Add assign_date and charge_upto variable for calculation purpose.
86 86
                          */
87
-                        $itemArr = array('description' => $charge_data['description'],
88
-                            'item_id' => $charge_data['id'],
89
-                            "type" => "SUBCHRG",
90
-                            "cycle" => $charge_data["sweep_id"],
91
-                            "assign_date"=>$accharges['assign_date'],
92
-                            "charge_upto"=>$accharges['charge_upto']);
87
+						$itemArr = array('description' => $charge_data['description'],
88
+							'item_id' => $charge_data['id'],
89
+							"type" => "SUBCHRG",
90
+							"cycle" => $charge_data["sweep_id"],
91
+							"assign_date"=>$accharges['assign_date'],
92
+							"charge_upto"=>$accharges['charge_upto']);
93 93
 			//Add a new arguement ($accharges) which have all information of charges.
94
-                        $lastdate = $this->calculate_charges($accountinfo, $itemArr, $charge_data["charge"], $fromdate, $todate, $charge_data["pro_rate"]);
95
-                        if ($lastdate) {
96
-                                               $this->db->update("charge_to_account", array("charge_upto" => $lastdate), array("charge_id" => $charge_data["id"], "accountid" => $accountinfo["id"]));
97
-                        }
98
-                    }
99
-                }
100
-            }
101
-        }
102
-    }
94
+						$lastdate = $this->calculate_charges($accountinfo, $itemArr, $charge_data["charge"], $fromdate, $todate, $charge_data["pro_rate"]);
95
+						if ($lastdate) {
96
+											   $this->db->update("charge_to_account", array("charge_upto" => $lastdate), array("charge_id" => $charge_data["id"], "accountid" => $accountinfo["id"]));
97
+						}
98
+					}
99
+				}
100
+			}
101
+		}
102
+	}
103 103
 
104
-    function process_DID_charges($AccountDATA, $startdate, $enddate, $Manualflg = false) {
105
-        $dids_data = $this->get_table_data("*", "dids", array("status" => "0", "accountid " => $AccountDATA["id"]));
106
-        $AccountDATA['original_sweep_id'] = $AccountDATA['sweep_id'];
107
-        $AccountDATA['sweep_id'] = '2';
108
-        if ($dids_data) {
109
-            foreach ($dids_data as $did_value) {
110
-                $charge_upto = ($did_value["charge_upto"] != "0000-00-00 00:00:00" && $did_value["charge_upto"] != "") ? $did_value["charge_upto"] : $did_value["assign_date"];
104
+	function process_DID_charges($AccountDATA, $startdate, $enddate, $Manualflg = false) {
105
+		$dids_data = $this->get_table_data("*", "dids", array("status" => "0", "accountid " => $AccountDATA["id"]));
106
+		$AccountDATA['original_sweep_id'] = $AccountDATA['sweep_id'];
107
+		$AccountDATA['sweep_id'] = '2';
108
+		if ($dids_data) {
109
+			foreach ($dids_data as $did_value) {
110
+				$charge_upto = ($did_value["charge_upto"] != "0000-00-00 00:00:00" && $did_value["charge_upto"] != "") ? $did_value["charge_upto"] : $did_value["assign_date"];
111 111
 
112
-                if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime($charge_upto) < strtotime($enddate)) {
113
-                    $fromdate = gmdate("Y-m-d H:i:s", strtotime($charge_upto));
114
-                    if ($Manualflg) {
115
-                        $todate = gmdate("Y-m-d H:i:s", strtotime($enddate));
116
-                    } else {
117
-                        $todate = gmdate("Y-m-d H:i:s", strtotime($did_value["upto_date"]));
118
-                    }
119
-                    $itemArr = array('description' => $did_value['number'],
120
-                                    'item_id' => $did_value['id'],
121
-                                    "type" => "DIDCHRG",
122
-                                    "cycle" => "2",
123
-                                    "assign_date"=>$did_value['assign_date'],
124
-                                    "charge_upto"=>$did_value['charge_upto']);
125
-                    if ($did_value['parent_id'] > 0) {
126
-                        $parent_id = $did_value['parent_id'];
127
-                        while ($parent_id != 0) {
128
-                            $reseller_dids = $this->get_table_data("*", "reseller_pricing", array("reseller_id" => $parent_id, "note" => $did_value['number']));
129
-                            $reseller_acc_data = $this->get_table_data("*", "accounts", array("id" => $parent_id));
130
-                            $reseller_acc_data = $reseller_acc_data['0'];
131
-                            $reseller_acc_data['sweep_id'] = '2';
132
-                            $reseller_dids = $reseller_dids[0];
133
-                            if (($parent_id == $reseller_dids['reseller_id'] && $did_value['accountid'] > 0) || $reseller_dids['parent_id'] == 0) {
134
-                                //Apply charges to resellers customers.
135
-                                $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
136
-                                if ($lastdate)
137
-                                    $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
138
-                            } else {
139
-                                //Apply charges to Resellers.
140
-                                $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
141
-                                if ($lastdate)
142
-                                    $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
143
-                            }
144
-                            $parent_id = $reseller_dids['parent_id'];
145
-                        }
146
-                    }
112
+				if ($charge_upto != "0000-00-00 00:00:00" && $charge_upto != "" && strtotime($charge_upto) < strtotime($enddate)) {
113
+					$fromdate = gmdate("Y-m-d H:i:s", strtotime($charge_upto));
114
+					if ($Manualflg) {
115
+						$todate = gmdate("Y-m-d H:i:s", strtotime($enddate));
116
+					} else {
117
+						$todate = gmdate("Y-m-d H:i:s", strtotime($did_value["upto_date"]));
118
+					}
119
+					$itemArr = array('description' => $did_value['number'],
120
+									'item_id' => $did_value['id'],
121
+									"type" => "DIDCHRG",
122
+									"cycle" => "2",
123
+									"assign_date"=>$did_value['assign_date'],
124
+									"charge_upto"=>$did_value['charge_upto']);
125
+					if ($did_value['parent_id'] > 0) {
126
+						$parent_id = $did_value['parent_id'];
127
+						while ($parent_id != 0) {
128
+							$reseller_dids = $this->get_table_data("*", "reseller_pricing", array("reseller_id" => $parent_id, "note" => $did_value['number']));
129
+							$reseller_acc_data = $this->get_table_data("*", "accounts", array("id" => $parent_id));
130
+							$reseller_acc_data = $reseller_acc_data['0'];
131
+							$reseller_acc_data['sweep_id'] = '2';
132
+							$reseller_dids = $reseller_dids[0];
133
+							if (($parent_id == $reseller_dids['reseller_id'] && $did_value['accountid'] > 0) || $reseller_dids['parent_id'] == 0) {
134
+								//Apply charges to resellers customers.
135
+								$lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
136
+								if ($lastdate)
137
+									$this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
138
+							} else {
139
+								//Apply charges to Resellers.
140
+								$lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
141
+								if ($lastdate)
142
+									$this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
143
+							}
144
+							$parent_id = $reseller_dids['parent_id'];
145
+						}
146
+					}
147 147
 //   		else{
148
-                    $lastdate = $this->calculate_charges($AccountDATA, $itemArr, $did_value["monthlycost"], $fromdate, $todate, "1");
149
-                    if ($lastdate)
150
-                      $this->db->update("dids", array("charge_upto" => $lastdate), array("id" => $did_value["id"], "accountid" => $AccountDATA["id"]));
148
+					$lastdate = $this->calculate_charges($AccountDATA, $itemArr, $did_value["monthlycost"], $fromdate, $todate, "1");
149
+					if ($lastdate)
150
+					  $this->db->update("dids", array("charge_upto" => $lastdate), array("id" => $did_value["id"], "accountid" => $AccountDATA["id"]));
151 151
 //            	}
152
-                }
153
-            }
154
-        }
155
-    }
152
+				}
153
+			}
154
+		}
155
+	}
156 156
 
157
-    /**
158
-     * @param string $fromdate
159
-     * @param string $todate
160
-     */
161
-    function calculate_charges($AccountDATA, $itemArr, $charge, $fromdate, $todate, $pro_rate = "1") {
162
-        $lastdate = false;
163
-        $billing_cycle = ($AccountDATA['sweep_id'] == "0") ? "1 day" : "1 month";
164
-        $last_invoice_date = $this->common->get_invoice_date("invoice_date", $AccountDATA['id'], $AccountDATA['reseller_id']);
165
-      //Below variable gives date based on assign or creation or monthly user billing day
166
-        $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : (($pro_rate == 0 && $AccountDATA['original_sweep_id'] == 2 && ($AccountDATA['invoice_day'] < gmdate("d", strtotime($itemArr['assign_date'])))) ? date("Y-m-".$AccountDATA['invoice_day']." 00:00:00") : (($pro_rate == 1 && $AccountDATA['original_sweep_id'] == 0) ? date("Y-m-d 00:00:00", strtotime($itemArr['assign_date'])) : date("Y-m-d 00:00:00", strtotime($AccountDATA['creation']))));
167
-        $last_invoice_date = ($last_invoice_date <= $fromdate) ? $last_invoice_date : $fromdate;
168
-        $Charges_date_range = array();
169
-        $prorate_array = array();
170
-        $daylen = 60 * 60 * 24;
171
-        /*Get assign day and billing day for postpaid monthly user.
157
+	/**
158
+	 * @param string $fromdate
159
+	 * @param string $todate
160
+	 */
161
+	function calculate_charges($AccountDATA, $itemArr, $charge, $fromdate, $todate, $pro_rate = "1") {
162
+		$lastdate = false;
163
+		$billing_cycle = ($AccountDATA['sweep_id'] == "0") ? "1 day" : "1 month";
164
+		$last_invoice_date = $this->common->get_invoice_date("invoice_date", $AccountDATA['id'], $AccountDATA['reseller_id']);
165
+	  //Below variable gives date based on assign or creation or monthly user billing day
166
+		$last_invoice_date = ($last_invoice_date) ? $last_invoice_date : (($pro_rate == 0 && $AccountDATA['original_sweep_id'] == 2 && ($AccountDATA['invoice_day'] < gmdate("d", strtotime($itemArr['assign_date'])))) ? date("Y-m-".$AccountDATA['invoice_day']." 00:00:00") : (($pro_rate == 1 && $AccountDATA['original_sweep_id'] == 0) ? date("Y-m-d 00:00:00", strtotime($itemArr['assign_date'])) : date("Y-m-d 00:00:00", strtotime($AccountDATA['creation']))));
167
+		$last_invoice_date = ($last_invoice_date <= $fromdate) ? $last_invoice_date : $fromdate;
168
+		$Charges_date_range = array();
169
+		$prorate_array = array();
170
+		$daylen = 60 * 60 * 24;
171
+		/*Get assign day and billing day for postpaid monthly user.
172 172
          */
173
-        $assign_day = ($AccountDATA['original_sweep_id'] == 2 && $AccountDATA['posttoexternal'] == 1) ? gmdate("d", strtotime($itemArr['assign_date'])) : 0;
174
-        $billing_day = ($AccountDATA['original_sweep_id'] == 2 && $AccountDATA['posttoexternal'] == 1) ? $AccountDATA['invoice_day'] : 0;
175
-        //Create an array if charge not applied yet and invoice day is greater than assign_day
176
-        if ($itemArr['charge_upto'] == "0000-00-00 00:00:00" && ($billing_day > $assign_day) && $pro_rate == 0 && $itemArr['cycle'] == 2 && $AccountDATA['original_sweep_id'] == 2) {
173
+		$assign_day = ($AccountDATA['original_sweep_id'] == 2 && $AccountDATA['posttoexternal'] == 1) ? gmdate("d", strtotime($itemArr['assign_date'])) : 0;
174
+		$billing_day = ($AccountDATA['original_sweep_id'] == 2 && $AccountDATA['posttoexternal'] == 1) ? $AccountDATA['invoice_day'] : 0;
175
+		//Create an array if charge not applied yet and invoice day is greater than assign_day
176
+		if ($itemArr['charge_upto'] == "0000-00-00 00:00:00" && ($billing_day > $assign_day) && $pro_rate == 0 && $itemArr['cycle'] == 2 && $AccountDATA['original_sweep_id'] == 2) {
177 177
 	  $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("-1 second", strtotime(date("Y-m-".$AccountDATA['invoice_day']." 00:00:00", strtotime($itemArr["assign_date"])))));
178 178
 	  $prorate_array[] = array("start_date" => date("Y-m-d H:i:s", strtotime($itemArr['assign_date'])), "end_date" => $last_invoice_date);
179 179
 	  
180
-        }
181
-        while (strtotime($last_invoice_date) <= strtotime($todate)) {
182
-            $startdate = $last_invoice_date;
183
-            $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+".$billing_cycle, strtotime($last_invoice_date)));
184
-            $Charges_date_range[] = array("start_date" =>gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($startdate))), "end_date" => $last_invoice_date);
185
-        }
186
-        if ( ! empty($prorate_array)) {
187
-         array_pop($Charges_date_range);
188
-         $Charges_date_range = array_merge($prorate_array, $Charges_date_range);
189
-        }
190
-        if ( ! empty($Charges_date_range)) {
191
-            foreach ($Charges_date_range as $ChargeVal) {
192
-                if (($pro_rate == 0 && $itemArr['cycle'] != 2) || (($billing_day <= $assign_day) && $pro_rate == 0 && $itemArr['cycle'] == 2 && $AccountDATA['original_sweep_id'] == 2)) {
193
-                    $ChargeVal['end_date'] = gmdate("Y-m-d 23:59:59", strtotime("-1 Day", strtotime($ChargeVal['end_date'])));
194
-                }
195
-                if ( ! empty($itemArr['charge_upto']) && empty($lastdate)) {
196
-                    $start_date = ($itemArr['charge_upto'] == '0000-00-00 00:00:00' && $AccountDATA['sweep_id'] == 2) ? $itemArr['assign_date'] : $ChargeVal['start_date'];
197
-                } else {
198
-                    $start_date = (empty($lastdate)) ? $ChargeVal['start_date'] : gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate)));
199
-                }
180
+		}
181
+		while (strtotime($last_invoice_date) <= strtotime($todate)) {
182
+			$startdate = $last_invoice_date;
183
+			$last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+".$billing_cycle, strtotime($last_invoice_date)));
184
+			$Charges_date_range[] = array("start_date" =>gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($startdate))), "end_date" => $last_invoice_date);
185
+		}
186
+		if ( ! empty($prorate_array)) {
187
+		 array_pop($Charges_date_range);
188
+		 $Charges_date_range = array_merge($prorate_array, $Charges_date_range);
189
+		}
190
+		if ( ! empty($Charges_date_range)) {
191
+			foreach ($Charges_date_range as $ChargeVal) {
192
+				if (($pro_rate == 0 && $itemArr['cycle'] != 2) || (($billing_day <= $assign_day) && $pro_rate == 0 && $itemArr['cycle'] == 2 && $AccountDATA['original_sweep_id'] == 2)) {
193
+					$ChargeVal['end_date'] = gmdate("Y-m-d 23:59:59", strtotime("-1 Day", strtotime($ChargeVal['end_date'])));
194
+				}
195
+				if ( ! empty($itemArr['charge_upto']) && empty($lastdate)) {
196
+					$start_date = ($itemArr['charge_upto'] == '0000-00-00 00:00:00' && $AccountDATA['sweep_id'] == 2) ? $itemArr['assign_date'] : $ChargeVal['start_date'];
197
+				} else {
198
+					$start_date = (empty($lastdate)) ? $ChargeVal['start_date'] : gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate)));
199
+				}
200 200
 
201
-                $lastdate = date("Y-m-d H:i:s", strtotime($ChargeVal['end_date']));
202
-                $end_date_str_time = strtotime("+1 Seconds", strtotime($lastdate));
203
-                $start_date_str_time = strtotime(gmdate("Y-m-d 00:00:00", strtotime($start_date)));
204
-                $temp_f_date = new DateTime(gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate))));
205
-                $temp_t_date = new DateTime($start_date);
206
-                $diff = $temp_f_date->diff($temp_t_date);
207
-                $month = (($diff->format('%y') * 12) + $diff->format('%m'));
208
-                $temp_charge = $charge;
209
-                if (($month != "1" || $pro_rate == "0") && $itemArr['cycle'] != '0') {
210
-                  //Calculate Number of days in month from start date
211
-                    $total_num_of_day = cal_days_in_month(CAL_GREGORIAN, date('m', $start_date_str_time), date('Y', $start_date_str_time));
212
-                    $days_diff = floor(($end_date_str_time - $start_date_str_time) / $daylen);
213
-                    $chrg_per_day = ($charge / $total_num_of_day);
214
-                    $temp_charge = ($chrg_per_day * $days_diff);
215
-                }
201
+				$lastdate = date("Y-m-d H:i:s", strtotime($ChargeVal['end_date']));
202
+				$end_date_str_time = strtotime("+1 Seconds", strtotime($lastdate));
203
+				$start_date_str_time = strtotime(gmdate("Y-m-d 00:00:00", strtotime($start_date)));
204
+				$temp_f_date = new DateTime(gmdate("Y-m-d H:i:s", strtotime("+1 second", strtotime($lastdate))));
205
+				$temp_t_date = new DateTime($start_date);
206
+				$diff = $temp_f_date->diff($temp_t_date);
207
+				$month = (($diff->format('%y') * 12) + $diff->format('%m'));
208
+				$temp_charge = $charge;
209
+				if (($month != "1" || $pro_rate == "0") && $itemArr['cycle'] != '0') {
210
+				  //Calculate Number of days in month from start date
211
+					$total_num_of_day = cal_days_in_month(CAL_GREGORIAN, date('m', $start_date_str_time), date('Y', $start_date_str_time));
212
+					$days_diff = floor(($end_date_str_time - $start_date_str_time) / $daylen);
213
+					$chrg_per_day = ($charge / $total_num_of_day);
214
+					$temp_charge = ($chrg_per_day * $days_diff);
215
+				}
216 216
                 
217
-                if (strtotime($ChargeVal['start_date']) < strtotime($ChargeVal['end_date'])) {
218
-                                    $this->Manage_invoice_item($AccountDATA, $itemArr['description'], $itemArr['item_id'], $temp_charge, $itemArr['type'], $start_date, $lastdate, $todate);
219
-                }
220
-                //                echo "<br/> ORG CHARG : " . $charge . " Charges : " . $temp_charge . "<br/>";
221
-            }
222
-        }
223
-        return $lastdate;
224
-    }
217
+				if (strtotime($ChargeVal['start_date']) < strtotime($ChargeVal['end_date'])) {
218
+									$this->Manage_invoice_item($AccountDATA, $itemArr['description'], $itemArr['item_id'], $temp_charge, $itemArr['type'], $start_date, $lastdate, $todate);
219
+				}
220
+				//                echo "<br/> ORG CHARG : " . $charge . " Charges : " . $temp_charge . "<br/>";
221
+			}
222
+		}
223
+		return $lastdate;
224
+	}
225 225
 
226
-    /**
227
-     * @param string $todate
228
-     */
229
-    function Manage_invoice_item($AccountData, $description, $item_id, $charge, $type, $fromdate, $todate, $invoicedate) {
230
-        $invoiceid = 0;
231
-        $Bal = "0.00"; 
232
-        if ($AccountData["posttoexternal"] == 0) {
233
-	    $reseller_id = $AccountData['type'] == 1 ? $AccountData['id'] : 0;
234
-	    $where = "accountid IN ('".$reseller_id."','1')";
235
-	    $this->db->where($where);
236
-	    $this->db->select('*');
237
-	    $this->db->order_by('accountid', 'desc');
238
-	    $this->db->limit(1);
239
-	    $invoiceconf = $this->db->get('invoice_conf');
240
-	    $invoice_conf = (array)$invoiceconf->first_row();
241
-	    $last_invoiceid = $this->common->get_invoice_date('invoiceid', '', $AccountData['reseller_id']);
242
-	    if ($last_invoiceid && $last_invoiceid > 0) {
243
-	    	$last_invoiceid = ($last_invoiceid + 1);
244
-  	    } else {
245
-	    	$last_invoiceid = $invoice_conf['invoice_start_from'];
246
-	    }
247
-	    $last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
248
-	    $invoice_prefix = $invoice_conf['invoice_prefix'];
249
-	    $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
226
+	/**
227
+	 * @param string $todate
228
+	 */
229
+	function Manage_invoice_item($AccountData, $description, $item_id, $charge, $type, $fromdate, $todate, $invoicedate) {
230
+		$invoiceid = 0;
231
+		$Bal = "0.00"; 
232
+		if ($AccountData["posttoexternal"] == 0) {
233
+		$reseller_id = $AccountData['type'] == 1 ? $AccountData['id'] : 0;
234
+		$where = "accountid IN ('".$reseller_id."','1')";
235
+		$this->db->where($where);
236
+		$this->db->select('*');
237
+		$this->db->order_by('accountid', 'desc');
238
+		$this->db->limit(1);
239
+		$invoiceconf = $this->db->get('invoice_conf');
240
+		$invoice_conf = (array)$invoiceconf->first_row();
241
+		$last_invoiceid = $this->common->get_invoice_date('invoiceid', '', $AccountData['reseller_id']);
242
+		if ($last_invoiceid && $last_invoiceid > 0) {
243
+			$last_invoiceid = ($last_invoiceid + 1);
244
+  		} else {
245
+			$last_invoiceid = $invoice_conf['invoice_start_from'];
246
+		}
247
+		$last_invoiceid = str_pad($last_invoiceid, (strlen($last_invoiceid) + 4), '0', STR_PAD_LEFT);
248
+		$invoice_prefix = $invoice_conf['invoice_prefix'];
249
+		$due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf['interval']." days"));
250 250
 
251
-            $invoiceid = $this->common_model->generate_receipt($AccountData["id"], $charge, $AccountData, $last_invoiceid, $invoice_prefix, $due_date);
252
-            $this->db->set('balance', 'balance-'.$charge, FALSE);
253
-            $this->db->where('id', $AccountData["id"]);
254
-            $this->db->update("accounts");
255
-            $AccountData['balance'] = ($AccountData['balance'] - $charge);
256
-            $Bal = $AccountData['balance'];
257
-        } else {
258
-            $Bal = ($AccountData["credit_limit"] - $AccountData["balance"]);
259
-        }
260
-        if ($Bal <= 0) {
261
-            $this->db->set('status', "1", FALSE);
262
-            $this->db->where('id', $AccountData["id"]);
263
-            $this->db->update("accounts");
264
-        }
265
-        $invoice_item_arr = array("accountid" => $AccountData["id"],
266
-            "reseller_id" => $AccountData["reseller_id"],
267
-            "description" => trim($description."-".$fromdate." to ".$todate),
268
-            "item_id" => $item_id, "debit" => $charge, "invoiceid" => $invoiceid,
269
-            "created_date" => trim($invoicedate),
270
-            "item_type" => $type
271
-        );
272
-        $this->manage_invoice($invoice_item_arr);
273
-    }
251
+			$invoiceid = $this->common_model->generate_receipt($AccountData["id"], $charge, $AccountData, $last_invoiceid, $invoice_prefix, $due_date);
252
+			$this->db->set('balance', 'balance-'.$charge, FALSE);
253
+			$this->db->where('id', $AccountData["id"]);
254
+			$this->db->update("accounts");
255
+			$AccountData['balance'] = ($AccountData['balance'] - $charge);
256
+			$Bal = $AccountData['balance'];
257
+		} else {
258
+			$Bal = ($AccountData["credit_limit"] - $AccountData["balance"]);
259
+		}
260
+		if ($Bal <= 0) {
261
+			$this->db->set('status', "1", FALSE);
262
+			$this->db->where('id', $AccountData["id"]);
263
+			$this->db->update("accounts");
264
+		}
265
+		$invoice_item_arr = array("accountid" => $AccountData["id"],
266
+			"reseller_id" => $AccountData["reseller_id"],
267
+			"description" => trim($description."-".$fromdate." to ".$todate),
268
+			"item_id" => $item_id, "debit" => $charge, "invoiceid" => $invoiceid,
269
+			"created_date" => trim($invoicedate),
270
+			"item_type" => $type
271
+		);
272
+		$this->manage_invoice($invoice_item_arr);
273
+	}
274 274
     
275
-    /**
276
-     * @param string $select
277
-     * @param string $table
278
-     */
279
-    function get_table_data($select, $table, $where) {
280
-        $query = $this->db_model->getSelect($select, $table, $where);
281
-        if ($query->num_rows > 0) {
282
-            $query_result = $query->result_array();
283
-            return $query_result;
284
-        } else {
285
-            return false;
286
-        }
287
-    }
275
+	/**
276
+	 * @param string $select
277
+	 * @param string $table
278
+	 */
279
+	function get_table_data($select, $table, $where) {
280
+		$query = $this->db_model->getSelect($select, $table, $where);
281
+		if ($query->num_rows > 0) {
282
+			$query_result = $query->result_array();
283
+			return $query_result;
284
+		} else {
285
+			return false;
286
+		}
287
+	}
288 288
 
289
-    function Manage_Invoice($invoice_item_arr) {
290
-       $this->db->insert("invoice_details", $invoice_item_arr);
291
-    }
289
+	function Manage_Invoice($invoice_item_arr) {
290
+	   $this->db->insert("invoice_details", $invoice_item_arr);
291
+	}
292 292
 
293 293
 }
294 294
 ?> 
Please login to merge, or discard this patch.
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -133,22 +133,25 @@
 block discarded – undo
133 133
                             if (($parent_id == $reseller_dids['reseller_id'] && $did_value['accountid'] > 0) || $reseller_dids['parent_id'] == 0) {
134 134
                                 //Apply charges to resellers customers.
135 135
                                 $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
136
-                                if ($lastdate)
137
-                                    $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
136
+                                if ($lastdate) {
137
+                                                                    $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
138
+                                }
138 139
                             } else {
139 140
                                 //Apply charges to Resellers.
140 141
                                 $lastdate = $this->calculate_charges($reseller_acc_data, $itemArr, $reseller_dids["monthlycost"], $fromdate, $todate, "1");
141
-                                if ($lastdate)
142
-                                    $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
142
+                                if ($lastdate) {
143
+                                                                    $this->db->update("reseller_pricing", array("charge_upto" => $lastdate), array("note" => $did_value["number"], "reseller_id" => $reseller_acc_data["id"]));
144
+                                }
143 145
                             }
144 146
                             $parent_id = $reseller_dids['parent_id'];
145 147
                         }
146 148
                     }
147 149
 //   		else{
148 150
                     $lastdate = $this->calculate_charges($AccountDATA, $itemArr, $did_value["monthlycost"], $fromdate, $todate, "1");
149
-                    if ($lastdate)
150
-                      $this->db->update("dids", array("charge_upto" => $lastdate), array("id" => $did_value["id"], "accountid" => $AccountDATA["id"]));
151
-//            	}
151
+                    if ($lastdate) {
152
+                                          $this->db->update("dids", array("charge_upto" => $lastdate), array("id" => $did_value["id"], "accountid" => $AccountDATA["id"]));
153
+                    }
154
+                    //            	}
152 155
                 }
153 156
             }
154 157
         }
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/generateInvoice.php 1 patch
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -24,264 +24,264 @@
 block discarded – undo
24 24
 
25 25
 class GenerateInvoice extends MX_Controller {
26 26
 
27
-    public static $global_config;
27
+	public static $global_config;
28 28
 
29
-    function __construct() {
30
-        parent::__construct();
31
-        $this->load->model("db_model");
32
-        $this->load->library("astpp/common");
33
-        $this->load->library('html2pdf');
34
-        ini_set("memory_limit", "2048M");
35
-        ini_set("max_execution_time", "259200");
36
-        $this->get_system_config();
37
-    }
29
+	function __construct() {
30
+		parent::__construct();
31
+		$this->load->model("db_model");
32
+		$this->load->library("astpp/common");
33
+		$this->load->library('html2pdf');
34
+		ini_set("memory_limit", "2048M");
35
+		ini_set("max_execution_time", "259200");
36
+		$this->get_system_config();
37
+	}
38 38
 
39
-    function get_system_config() {
40
-        $query = $this->db->get("system");
41
-        $config = array();
42
-        $result = $query->result_array();
43
-        foreach ($result as $row) {
44
-            $config[$row['name']] = $row['value'];
45
-        }
46
-        self::$global_config['system_config'] = $config;
47
-    }
39
+	function get_system_config() {
40
+		$query = $this->db->get("system");
41
+		$config = array();
42
+		$result = $query->result_array();
43
+		foreach ($result as $row) {
44
+			$config[$row['name']] = $row['value'];
45
+		}
46
+		self::$global_config['system_config'] = $config;
47
+	}
48 48
 
49
-    function getInvoiceData() {
50
-        $where = array("posttoexternal" => 1, "deleted" => "0", "status" => "0");
51
-        $query = $this->db_model->getSelect("*", "accounts", $where);
52
-        if ($query->num_rows > 0) {
53
-            $account_data = $query->result_array();
54
-            foreach ($account_data as $data_key => $account_value) {
55
-                $end_date = gmdate("Y-m-d")." 23:59:59";
56
-                $account_value['sweep_id'] = (int)$account_value['sweep_id'];
57
-                switch ($account_value['sweep_id']) {
58
-                    case 0:
59
-                        $start_date = $this->validate_invoice_date($account_value);
60
-                        if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) {
61
-                            $start_date = gmdate("Y-m-d H:i:s");
62
-                        }
63
-                        $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 days"));
64
-                        $this->Generate_Daily_invoice($account_value, $start_date, $end_date);
65
-                        break;
66
-                    case 2:
67
-                        if (date("d") == $account_value['invoice_day']) {
68
-                            $start_date = $this->validate_invoice_date($account_value);
69
-                            if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) {
70
-                                $start_date = gmdate("Y-m-d H:i:s");
71
-                            }
72
-                            $end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 month"));
73
-                            $this->Generate_Monthly_invoice($account_value, $start_date, $end_date);
74
-                        }
75
-                        break;
76
-                }
77
-            }
78
-            $screen_path = getcwd()."/cron";
79
-            $screen_filename = "Email_Broadcast_".strtotime('now');
80
-            $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
81
-            exec($command);
82
-        }
83
-    }
49
+	function getInvoiceData() {
50
+		$where = array("posttoexternal" => 1, "deleted" => "0", "status" => "0");
51
+		$query = $this->db_model->getSelect("*", "accounts", $where);
52
+		if ($query->num_rows > 0) {
53
+			$account_data = $query->result_array();
54
+			foreach ($account_data as $data_key => $account_value) {
55
+				$end_date = gmdate("Y-m-d")." 23:59:59";
56
+				$account_value['sweep_id'] = (int)$account_value['sweep_id'];
57
+				switch ($account_value['sweep_id']) {
58
+					case 0:
59
+						$start_date = $this->validate_invoice_date($account_value);
60
+						if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) {
61
+							$start_date = gmdate("Y-m-d H:i:s");
62
+						}
63
+						$end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 days"));
64
+						$this->Generate_Daily_invoice($account_value, $start_date, $end_date);
65
+						break;
66
+					case 2:
67
+						if (date("d") == $account_value['invoice_day']) {
68
+							$start_date = $this->validate_invoice_date($account_value);
69
+							if (strtotime($start_date) >= strtotime(gmdate("Y-m-d H:i:s"))) {
70
+								$start_date = gmdate("Y-m-d H:i:s");
71
+							}
72
+							$end_date = gmdate("Y-m-d 23:59:59", strtotime($start_date." + 1 month"));
73
+							$this->Generate_Monthly_invoice($account_value, $start_date, $end_date);
74
+						}
75
+						break;
76
+				}
77
+			}
78
+			$screen_path = getcwd()."/cron";
79
+			$screen_filename = "Email_Broadcast_".strtotime('now');
80
+			$command = "cd ".$screen_path." && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
81
+			exec($command);
82
+		}
83
+	}
84 84
 
85
-    function validate_invoice_date($account_value) {
86
-        $last_invoice_date = $this->common->get_invoice_date("to_date", $account_value["id"], $account_value['reseller_id'], "to_date");
87
-        $last_invoice_date = ($last_invoice_date) ? $last_invoice_date : $account_value['creation'];
88
-        $last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($last_invoice_date)));
89
-        return $last_invoice_date;
90
-    }
85
+	function validate_invoice_date($account_value) {
86
+		$last_invoice_date = $this->common->get_invoice_date("to_date", $account_value["id"], $account_value['reseller_id'], "to_date");
87
+		$last_invoice_date = ($last_invoice_date) ? $last_invoice_date : $account_value['creation'];
88
+		$last_invoice_date = gmdate("Y-m-d H:i:s", strtotime("+1 Second", strtotime($last_invoice_date)));
89
+		return $last_invoice_date;
90
+	}
91 91
 
92
-    /**
93
-     * @param string $start_date
94
-     * @param string $end_date
95
-     */
96
-    function Generate_Daily_invoice($account_value, $start_date, $end_date) {
97
-        //  echo "INVOICE SCRIPT-------start date :".$start_date."-------end date....".$end_date;
92
+	/**
93
+	 * @param string $start_date
94
+	 * @param string $end_date
95
+	 */
96
+	function Generate_Daily_invoice($account_value, $start_date, $end_date) {
97
+		//  echo "INVOICE SCRIPT-------start date :".$start_date."-------end date....".$end_date;
98 98
 
99
-        require_once('updateBalance.php');
100
-        $updateBalance = new updateBalance();
101
-        $updateBalance->process_subscriptions($account_value, $start_date, $end_date, TRUE);
102
-        $updateBalance->process_DID_charges($account_value, $start_date, $end_date, TRUE);
103
-        $this->process_invoice($account_value, $start_date, $end_date);
104
-    }
99
+		require_once('updateBalance.php');
100
+		$updateBalance = new updateBalance();
101
+		$updateBalance->process_subscriptions($account_value, $start_date, $end_date, TRUE);
102
+		$updateBalance->process_DID_charges($account_value, $start_date, $end_date, TRUE);
103
+		$this->process_invoice($account_value, $start_date, $end_date);
104
+	}
105 105
 
106
-    /**
107
-     * @param string $start_date
108
-     * @param string $end_date
109
-     */
110
-    function Generate_Monthly_invoice($account_value, $start_date, $end_date) {
111
-        require_once('updateBalance.php');
112
-        $updateBalance = new updateBalance();
113
-        $updateBalance->process_subscriptions($account_value, $start_date, $end_date, TRUE);
114
-        $updateBalance->process_DID_charges($account_value, $start_date, $end_date, TRUE); 
115
-        $this->process_invoice($account_value, $start_date, $end_date);
116
-    }
106
+	/**
107
+	 * @param string $start_date
108
+	 * @param string $end_date
109
+	 */
110
+	function Generate_Monthly_invoice($account_value, $start_date, $end_date) {
111
+		require_once('updateBalance.php');
112
+		$updateBalance = new updateBalance();
113
+		$updateBalance->process_subscriptions($account_value, $start_date, $end_date, TRUE);
114
+		$updateBalance->process_DID_charges($account_value, $start_date, $end_date, TRUE); 
115
+		$this->process_invoice($account_value, $start_date, $end_date);
116
+	}
117 117
 
118
-    function process_invoice($accountdata, $start_date, $end_date) {
119
-        //Get Invoice configuration using single query instead of multiple queries.
120
-        $invoice_conf = array();
121
-        $reseller_id = ($accountdata['reseller_id'] == 0) ? 1 : $accountdata['reseller_id'];
122
-        $where = "accountid IN ('".$reseller_id."','1')";
123
-        $this->db->select('*');
124
-        $this->db->where($where);
125
-        $this->db->order_by('accountid', 'desc');
126
-        $this->db->limit(1);
127
-        $invoice_conf = $this->db->get('invoice_conf');
128
-        $invoice_conf = (array)$invoice_conf->first_row();
129
-        /*******************************************************/
130
-        $last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $accountdata['reseller_id']);
131
-        if ($last_invoice_ID && $last_invoice_ID > 0) {
132
-            $last_invoice_ID = ($last_invoice_ID + 1);
133
-        } else {
134
-            $last_invoice_ID = $invoice_conf['invoice_start_from'];
135
-        }
136
-        $last_invoice_ID = str_pad($last_invoice_ID, (strlen($last_invoice_ID) + 4), '0', STR_PAD_LEFT);
137
-        $invoice_sub_total = $this->count_invoice_data($accountdata, $start_date, $end_date);
138
-        if ($invoice_sub_total > 0) {
139
-            $invoiceid = $this->create_invoice($accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf['invoice_prefix'], $invoice_conf);
140
-            $this->update_cdrs_data($accountdata['id'], $invoiceid, $start_date, $end_date);
141
-            $sort_order = $this->common_model->apply_invoice_taxes($invoiceid, $accountdata, $start_date);
142
-            $invoice_total = $this->set_invoice_total($invoiceid, $accountdata['id']);
143
-            $this->download_invoice($invoiceid, $accountdata, $invoice_conf);
144
-        } else {
145
-            $invoiceid = $this->create_invoice($accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf['invoice_prefix'], $invoice_conf);
146
-            $sort_order = $this->common_model->apply_invoice_taxes($invoiceid, $accountdata, $start_date);
147
-            $invoice_total = $this->set_invoice_total($invoiceid, $accountdata['id']);
148
-        }
149
-    }
118
+	function process_invoice($accountdata, $start_date, $end_date) {
119
+		//Get Invoice configuration using single query instead of multiple queries.
120
+		$invoice_conf = array();
121
+		$reseller_id = ($accountdata['reseller_id'] == 0) ? 1 : $accountdata['reseller_id'];
122
+		$where = "accountid IN ('".$reseller_id."','1')";
123
+		$this->db->select('*');
124
+		$this->db->where($where);
125
+		$this->db->order_by('accountid', 'desc');
126
+		$this->db->limit(1);
127
+		$invoice_conf = $this->db->get('invoice_conf');
128
+		$invoice_conf = (array)$invoice_conf->first_row();
129
+		/*******************************************************/
130
+		$last_invoice_ID = $this->common->get_invoice_date("invoiceid", "", $accountdata['reseller_id']);
131
+		if ($last_invoice_ID && $last_invoice_ID > 0) {
132
+			$last_invoice_ID = ($last_invoice_ID + 1);
133
+		} else {
134
+			$last_invoice_ID = $invoice_conf['invoice_start_from'];
135
+		}
136
+		$last_invoice_ID = str_pad($last_invoice_ID, (strlen($last_invoice_ID) + 4), '0', STR_PAD_LEFT);
137
+		$invoice_sub_total = $this->count_invoice_data($accountdata, $start_date, $end_date);
138
+		if ($invoice_sub_total > 0) {
139
+			$invoiceid = $this->create_invoice($accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf['invoice_prefix'], $invoice_conf);
140
+			$this->update_cdrs_data($accountdata['id'], $invoiceid, $start_date, $end_date);
141
+			$sort_order = $this->common_model->apply_invoice_taxes($invoiceid, $accountdata, $start_date);
142
+			$invoice_total = $this->set_invoice_total($invoiceid, $accountdata['id']);
143
+			$this->download_invoice($invoiceid, $accountdata, $invoice_conf);
144
+		} else {
145
+			$invoiceid = $this->create_invoice($accountdata, $start_date, $end_date, $last_invoice_ID, $invoice_conf['invoice_prefix'], $invoice_conf);
146
+			$sort_order = $this->common_model->apply_invoice_taxes($invoiceid, $accountdata, $start_date);
147
+			$invoice_total = $this->set_invoice_total($invoiceid, $accountdata['id']);
148
+		}
149
+	}
150 150
 
151
-    function count_invoice_data($account, $start_date = "", $end_date = "") {
152
-        $cdr_query = "";
153
-        $inv_data_query = "";
154
-        $cdr_query = "select calltype,sum(debit) as debit from cdrs where accountid = ".$account['id'];
155
-        $cdr_query .= " AND callstart >='".$start_date."' AND callstart <= '".$end_date."' AND invoiceid=0 group by calltype";
151
+	function count_invoice_data($account, $start_date = "", $end_date = "") {
152
+		$cdr_query = "";
153
+		$inv_data_query = "";
154
+		$cdr_query = "select calltype,sum(debit) as debit from cdrs where accountid = ".$account['id'];
155
+		$cdr_query .= " AND callstart >='".$start_date."' AND callstart <= '".$end_date."' AND invoiceid=0 group by calltype";
156 156
 //echo $cdr_query; 
157
-        $cdr_data = $this->db->query($cdr_query);
158
-        if ($cdr_data->num_rows > 0) {
159
-            $cdr_data = $cdr_data->result_array();
160
-            //echo '<pre>'; print_r($cdr_data); exit;
161
-            foreach ($cdr_data as $cdrvalue) {
162
-                $cdrvalue['debit'] = round($cdrvalue['debit'], self::$global_config['system_config']['decimalpoints']);
163
-                $tempArr = array("accountid" => $account['id'], "reseller_id" => $account['reseller_id'], "item_id" => "0",
164
-                    "description" => $cdrvalue['calltype']." CALLS for the period (".$start_date." to ".$end_date, "debit" => $cdrvalue['debit'], "item_type" => $cdrvalue['calltype'], "created_date" => $end_date);
165
-                $this->db->insert("invoice_details", $tempArr);
166
-            }
167
-        }
168
-        $inv_data_query = "select count(id) as count,sum(debit) as debit,sum(credit) as credit from invoice_details where accountid=".$account['id']." AND created_date >='".$start_date."' AND created_date <= '".$end_date."'  AND invoiceid=0 AND item_type != 'FREECALL'";
157
+		$cdr_data = $this->db->query($cdr_query);
158
+		if ($cdr_data->num_rows > 0) {
159
+			$cdr_data = $cdr_data->result_array();
160
+			//echo '<pre>'; print_r($cdr_data); exit;
161
+			foreach ($cdr_data as $cdrvalue) {
162
+				$cdrvalue['debit'] = round($cdrvalue['debit'], self::$global_config['system_config']['decimalpoints']);
163
+				$tempArr = array("accountid" => $account['id'], "reseller_id" => $account['reseller_id'], "item_id" => "0",
164
+					"description" => $cdrvalue['calltype']." CALLS for the period (".$start_date." to ".$end_date, "debit" => $cdrvalue['debit'], "item_type" => $cdrvalue['calltype'], "created_date" => $end_date);
165
+				$this->db->insert("invoice_details", $tempArr);
166
+			}
167
+		}
168
+		$inv_data_query = "select count(id) as count,sum(debit) as debit,sum(credit) as credit from invoice_details where accountid=".$account['id']." AND created_date >='".$start_date."' AND created_date <= '".$end_date."'  AND invoiceid=0 AND item_type != 'FREECALL'";
169 169
 //echo $inv_data_query;         
170
-        $invoice_data = $this->db->query($inv_data_query);
171
-        if ($invoice_data->num_rows > 0) {
172
-            $invoice_data = $invoice_data->result_array();
173
-            foreach ($invoice_data as $data_value) {
174
-                if ($data_value['count'] > 0) {
175
-                    $sub_total = ($data_value['debit'] - $data_value['credit']);
176
-                    $sub_total = round($sub_total, self::$global_config['system_config']['decimalpoints']);
177
-                    return $sub_total;
178
-                }
179
-            }
180
-        }
181
-        return "0";
182
-    }
170
+		$invoice_data = $this->db->query($inv_data_query);
171
+		if ($invoice_data->num_rows > 0) {
172
+			$invoice_data = $invoice_data->result_array();
173
+			foreach ($invoice_data as $data_value) {
174
+				if ($data_value['count'] > 0) {
175
+					$sub_total = ($data_value['debit'] - $data_value['credit']);
176
+					$sub_total = round($sub_total, self::$global_config['system_config']['decimalpoints']);
177
+					return $sub_total;
178
+				}
179
+			}
180
+		}
181
+		return "0";
182
+	}
183 183
 
184
-    //Change Order of arguements
185
-    function update_cdrs_data($accountid, $invoiceid, $start_date = "", $end_date = "") {
186
-        $inv_data_query = "update invoice_details SET invoiceid = '".$invoiceid."' where accountid=".$accountid;
187
-        $inv_data_query .= " AND created_date >='".$start_date."' AND created_date <= '".$end_date."'  AND invoiceid=0 AND item_type !='PAYMENT'";
188
-        $this->db->query($inv_data_query);
189
-        return true;
190
-    }
184
+	//Change Order of arguements
185
+	function update_cdrs_data($accountid, $invoiceid, $start_date = "", $end_date = "") {
186
+		$inv_data_query = "update invoice_details SET invoiceid = '".$invoiceid."' where accountid=".$accountid;
187
+		$inv_data_query .= " AND created_date >='".$start_date."' AND created_date <= '".$end_date."'  AND invoiceid=0 AND item_type !='PAYMENT'";
188
+		$this->db->query($inv_data_query);
189
+		return true;
190
+	}
191 191
 
192
-    /**
193
-     * @param string $last_invoice_ID
194
-     */
195
-    function create_invoice($account, $from_date, $to_date, $last_invoice_ID, $INVprefix, $invoiceconf) {
196
-        //$due_date = gmdate("Y-m-d H:i:s",strtotime($to_date." +".$invoiceconf['interval']." days"));
197
-        if ($invoiceconf['interval'] > 0) {
198
-            $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoiceconf['interval']." days"));
199
-        } else {
200
-            $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +7 days"));
201
-        }
202
-        // echo "due daye-------".$due_date.'----------'.$to_date.'------------> Invoice interval'.$invoiceconf['interval']; 
203
-        $balance = ($account['credit_limit'] - $account['balance']);
204
-        $automatic_flag = self::$global_config['system_config']['automatic_invoice'];
192
+	/**
193
+	 * @param string $last_invoice_ID
194
+	 */
195
+	function create_invoice($account, $from_date, $to_date, $last_invoice_ID, $INVprefix, $invoiceconf) {
196
+		//$due_date = gmdate("Y-m-d H:i:s",strtotime($to_date." +".$invoiceconf['interval']." days"));
197
+		if ($invoiceconf['interval'] > 0) {
198
+			$due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoiceconf['interval']." days"));
199
+		} else {
200
+			$due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +7 days"));
201
+		}
202
+		// echo "due daye-------".$due_date.'----------'.$to_date.'------------> Invoice interval'.$invoiceconf['interval']; 
203
+		$balance = ($account['credit_limit'] - $account['balance']);
204
+		$automatic_flag = self::$global_config['system_config']['automatic_invoice'];
205 205
 	if ($automatic_flag == 1) {
206
-	        $invoice_data = array("accountid" => $account['id'], "invoice_prefix" => $INVprefix, "invoiceid" => $last_invoice_ID, "reseller_id" =>
207
-            $account['reseller_id'], "invoice_date" => gmdate("Y-m-d H:i:s"), "from_date" => $from_date, "to_date" => $to_date, "due_date" => $due_date, "status" => 1, "amount" => "0.00", "balance" => $balance);
206
+			$invoice_data = array("accountid" => $account['id'], "invoice_prefix" => $INVprefix, "invoiceid" => $last_invoice_ID, "reseller_id" =>
207
+			$account['reseller_id'], "invoice_date" => gmdate("Y-m-d H:i:s"), "from_date" => $from_date, "to_date" => $to_date, "due_date" => $due_date, "status" => 1, "amount" => "0.00", "balance" => $balance);
208 208
 	} else {
209
-	        $invoice_data = array("accountid" => $account['id'], "invoice_prefix" => $INVprefix, "invoiceid" => $last_invoice_ID, "reseller_id" =>
210
-            $account['reseller_id'], "invoice_date" => gmdate("Y-m-d H:i:s"), "from_date" => $from_date, "to_date" => $to_date, "due_date" => $due_date, "status" => 1, "amount" => "0.00", "balance" => $balance, "confirm" => 1);
209
+			$invoice_data = array("accountid" => $account['id'], "invoice_prefix" => $INVprefix, "invoiceid" => $last_invoice_ID, "reseller_id" =>
210
+			$account['reseller_id'], "invoice_date" => gmdate("Y-m-d H:i:s"), "from_date" => $from_date, "to_date" => $to_date, "due_date" => $due_date, "status" => 1, "amount" => "0.00", "balance" => $balance, "confirm" => 1);
211 211
 	}
212
-        // echo "<pre>"; print_r($invoice_data); exit;
213
-        $this->db->insert("invoices", $invoice_data);
214
-        $invoiceid = $this->db->insert_id();
212
+		// echo "<pre>"; print_r($invoice_data); exit;
213
+		$this->db->insert("invoices", $invoice_data);
214
+		$invoiceid = $this->db->insert_id();
215 215
 	if ($automatic_flag == 0) {
216
-            $this->download_invoice($invoiceid, $account, $invoiceconf);
216
+			$this->download_invoice($invoiceid, $account, $invoiceconf);
217
+	}
218
+		return $invoiceid;
217 219
 	}
218
-        return $invoiceid;
219
-    }
220 220
 
221
-    function set_invoice_total($invoiceid, $accountid) {
222
-        $query = $this->db_model->getSelect("SUM(debit) as total", "invoice_details", array("invoiceid" => $invoiceid, "item_type <>" => "FREECALL"));
223
-        $query = $query->result_array();
224
-        $sub_total = $query["0"]["total"];
225
-        $updateArr = array("amount" => $sub_total);
226
-        $this->db->where(array("id" => $invoiceid));
227
-        $this->db->update("invoices", $updateArr);
221
+	function set_invoice_total($invoiceid, $accountid) {
222
+		$query = $this->db_model->getSelect("SUM(debit) as total", "invoice_details", array("invoiceid" => $invoiceid, "item_type <>" => "FREECALL"));
223
+		$query = $query->result_array();
224
+		$sub_total = $query["0"]["total"];
225
+		$updateArr = array("amount" => $sub_total);
226
+		$this->db->where(array("id" => $invoiceid));
227
+		$this->db->update("invoices", $updateArr);
228 228
 
229
-        $updateArr = array("balance" => "0.00");
230
-        $this->db->where(array("id" => $accountid));
231
-        $this->db->update("accounts", $updateArr);
229
+		$updateArr = array("balance" => "0.00");
230
+		$this->db->where(array("id" => $accountid));
231
+		$this->db->update("accounts", $updateArr);
232 232
 
233
-        return true;
234
-    }
233
+		return true;
234
+	}
235 235
 
236
-    function download_invoice($invoiceid, $accountdata, $invoice_conf) {
237
-        $invoicedata = $this->db_model->getSelect("*", "invoices", array("id" => $invoiceid));
238
-        $invoicedata = $invoicedata->result_array();
239
-        $invoicedata = $invoicedata[0];
240
-        $FilePath = FCPATH."invoices/".$accountdata["id"].'/'.$invoicedata['invoice_prefix']."".$invoicedata['invoiceid']."_invoice.pdf";
241
-        $Filenm = $invoicedata['invoice_prefix']."_".$invoicedata['invoiceid']."_invoice.pdf";
242
-        $this->common->get_invoice_template($invoicedata, $accountdata, false);
243
-        if ($invoice_conf['invoice_notification']) {
244
-            $this->send_email_notification($FilePath, $Filenm, $accountdata, $invoice_conf, $invoicedata);
245
-        }
246
-    }
236
+	function download_invoice($invoiceid, $accountdata, $invoice_conf) {
237
+		$invoicedata = $this->db_model->getSelect("*", "invoices", array("id" => $invoiceid));
238
+		$invoicedata = $invoicedata->result_array();
239
+		$invoicedata = $invoicedata[0];
240
+		$FilePath = FCPATH."invoices/".$accountdata["id"].'/'.$invoicedata['invoice_prefix']."".$invoicedata['invoiceid']."_invoice.pdf";
241
+		$Filenm = $invoicedata['invoice_prefix']."_".$invoicedata['invoiceid']."_invoice.pdf";
242
+		$this->common->get_invoice_template($invoicedata, $accountdata, false);
243
+		if ($invoice_conf['invoice_notification']) {
244
+			$this->send_email_notification($FilePath, $Filenm, $accountdata, $invoice_conf, $invoicedata);
245
+		}
246
+	}
247 247
 
248
-    /**
249
-     * @param string $FilePath
250
-     * @param string $Filenm
251
-     */
252
-    function send_email_notification($FilePath, $Filenm, $AccountData, $invoice_conf, $invData) {
253
-        $TemplateData = array();
254
-        $where = array('name' => 'email_new_invoice');
255
-        $EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where);
256
-        foreach ($EmailTemplate->result_array() as $TemplateVal) {
257
-            $TemplateData = $TemplateVal;
258
-            $TemplateData['subject'] = str_replace('#NAME#', $AccountData['first_name']." ".$AccountData['last_name'], $TemplateData['subject']);
259
-            $TemplateData['subject'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'].$invData['invoiceid'], $TemplateData['subject']);
260
-            $TemplateData['template'] = str_replace('#NAME#', $AccountData['first_name']." ".$AccountData['last_name'], $TemplateData['template']);
261
-            $TemplateData['template'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'].$invData['invoiceid'], $TemplateData['template']);
262
-            $TemplateData['template'] = str_replace('#AMOUNT#', $invData['amount'], $TemplateData['template']);
248
+	/**
249
+	 * @param string $FilePath
250
+	 * @param string $Filenm
251
+	 */
252
+	function send_email_notification($FilePath, $Filenm, $AccountData, $invoice_conf, $invData) {
253
+		$TemplateData = array();
254
+		$where = array('name' => 'email_new_invoice');
255
+		$EmailTemplate = $this->db_model->getSelect("*", "default_templates", $where);
256
+		foreach ($EmailTemplate->result_array() as $TemplateVal) {
257
+			$TemplateData = $TemplateVal;
258
+			$TemplateData['subject'] = str_replace('#NAME#', $AccountData['first_name']." ".$AccountData['last_name'], $TemplateData['subject']);
259
+			$TemplateData['subject'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'].$invData['invoiceid'], $TemplateData['subject']);
260
+			$TemplateData['template'] = str_replace('#NAME#', $AccountData['first_name']." ".$AccountData['last_name'], $TemplateData['template']);
261
+			$TemplateData['template'] = str_replace('#INVOICE_NUMBER#', $invData['invoice_prefix'].$invData['invoiceid'], $TemplateData['template']);
262
+			$TemplateData['template'] = str_replace('#AMOUNT#', $invData['amount'], $TemplateData['template']);
263 263
 
264
-            $TemplateData['template'] = str_replace("#COMPANY_EMAIL#", $invoice_conf['emailaddress'], $TemplateData['template']);
265
-            $TemplateData['template'] = str_replace("#COMPANY_NAME#", $invoice_conf['company_name'], $TemplateData['template']);
266
-            $TemplateData['template'] = str_replace("#COMPANY_WEBSITE#", $invoice_conf['website'], $TemplateData['template']);
267
-            $TemplateData['template'] = str_replace("#INVOICE_DATE#", $invData['invoice_date'], $TemplateData['template']);
268
-            $TemplateData['template'] = str_replace("#DUE_DATE#", $invData['due_date'], $TemplateData['template']);
269
-        }
270
-        $dir_path = getcwd()."/attachments/";
271
-        $path = $dir_path.$Filenm;
272
-        $command = "cp ".$FilePath." ".$path;
273
-        exec($command);
274
-        $email_array = array('accountid' => $AccountData['id'],
275
-            'subject' => $TemplateData['subject'],
276
-            'body' => $TemplateData['template'],
277
-            'from' => $invoice_conf['emailaddress'],
278
-            'to' => $AccountData['email'],
279
-            'status' => "1",
280
-            'attachment' => $Filenm,
281
-            'template' => '');
282
-        //echo "<pre>"; print_r($TemplateData); exit;
283
-        $this->db->insert("mail_details", $email_array);
284
-    }
264
+			$TemplateData['template'] = str_replace("#COMPANY_EMAIL#", $invoice_conf['emailaddress'], $TemplateData['template']);
265
+			$TemplateData['template'] = str_replace("#COMPANY_NAME#", $invoice_conf['company_name'], $TemplateData['template']);
266
+			$TemplateData['template'] = str_replace("#COMPANY_WEBSITE#", $invoice_conf['website'], $TemplateData['template']);
267
+			$TemplateData['template'] = str_replace("#INVOICE_DATE#", $invData['invoice_date'], $TemplateData['template']);
268
+			$TemplateData['template'] = str_replace("#DUE_DATE#", $invData['due_date'], $TemplateData['template']);
269
+		}
270
+		$dir_path = getcwd()."/attachments/";
271
+		$path = $dir_path.$Filenm;
272
+		$command = "cp ".$FilePath." ".$path;
273
+		exec($command);
274
+		$email_array = array('accountid' => $AccountData['id'],
275
+			'subject' => $TemplateData['subject'],
276
+			'body' => $TemplateData['template'],
277
+			'from' => $invoice_conf['emailaddress'],
278
+			'to' => $AccountData['email'],
279
+			'status' => "1",
280
+			'attachment' => $Filenm,
281
+			'template' => '');
282
+		//echo "<pre>"; print_r($TemplateData); exit;
283
+		$this->db->insert("mail_details", $email_array);
284
+	}
285 285
 
286 286
 }
287 287
 
Please login to merge, or discard this patch.
web_interface/astpp/application/controllers/broadcastemail.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,21 +25,21 @@
 block discarded – undo
25 25
 	function __construct()
26 26
 	{
27 27
 	parent::__construct();
28
-	if(!defined( 'CRON' ) )  
28
+	if ( ! defined('CRON'))  
29 29
 	  exit();
30 30
 		$this->load->model("db_model");
31 31
 		$this->load->library("astpp/email_lib");
32 32
 	}
33
-	function broadcast_email(){
33
+	function broadcast_email() {
34 34
 	
35 35
 	   $where = array("status"=>"1");
36 36
 		$query = $this->db_model->getSelect("*", "mail_details", $where);
37
-		if($query->num_rows >0){
37
+		if ($query->num_rows > 0) {
38 38
 			$account_data = $query->result_array();
39
-			foreach($account_data as $data_key =>$account_value){
40
-			 $account_value['history_id']=$account_value['id'];
39
+			foreach ($account_data as $data_key =>$account_value) {
40
+			 $account_value['history_id'] = $account_value['id'];
41 41
 			 unset($account_value['id']);
42
-			 $this->email_lib->send_email('',$account_value,'',$account_value['attachment'],1,0,1);
42
+			 $this->email_lib->send_email('', $account_value, '', $account_value['attachment'], 1, 0, 1);
43 43
 			}
44 44
 		}
45 45
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@
 block discarded – undo
25 25
 	function __construct()
26 26
 	{
27 27
 	parent::__construct();
28
-	if(!defined( 'CRON' ) )  
29
-	  exit();
28
+	if(!defined( 'CRON' ) ) {
29
+		  exit();
30
+	}
30 31
 		$this->load->model("db_model");
31 32
 		$this->load->library("astpp/email_lib");
32 33
 	}
Please login to merge, or discard this patch.
web_interface/astpp/application/libraries/locale.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  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
  * Dynamically build forms for display
29 29
  */
30
-class Locale{
30
+class Locale {
31 31
 
32 32
 	function __construct($library_name = '') {
33 33
 
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
 		$this->CI->load->driver('cache');
39 39
 	$this->set_lang();
40 40
 	}
41
-	function set_lang($lang=FALSE){
41
+	function set_lang($lang = FALSE) {
42 42
 
43
-		$current_locale=$this->CI->session->userdata('user_language');
44
-		if(empty($current_locale)){
45
-			 $current_locale= 'en_US';
43
+		$current_locale = $this->CI->session->userdata('user_language');
44
+		if (empty($current_locale)) {
45
+			 $current_locale = 'en_US';
46 46
 		}
47 47
 	putenv("LANG=$current_locale");
48 48
 	setlocale(LC_ALL, $current_locale.".UTF-8");
49
-		setlocale(LC_MESSAGES,$current_locale);
49
+		setlocale(LC_MESSAGES, $current_locale);
50 50
 	setlocale(LC_TIME, $current_locale);
51
-		setlocale(LC_CTYPE,$current_locale);
52
-	$domain='messages';
53
-	$uri_segment='';
51
+		setlocale(LC_CTYPE, $current_locale);
52
+	$domain = 'messages';
53
+	$uri_segment = '';
54 54
 	 $uri_segment = $this->CI->uri->segments;
55
-	if(isset($uri_segment[1])){	
55
+	if (isset($uri_segment[1])) {	
56 56
 		$filename = getcwd().'/application/modules/user/language/'.$lang.'/LC_MESSAGES/messages.mo';
57
-				bindtextdomain(WEBSITE_DOMAIN,getcwd().'/application/modules/'.$uri_segment[1].'/language/');
57
+				bindtextdomain(WEBSITE_DOMAIN, getcwd().'/application/modules/'.$uri_segment[1].'/language/');
58 58
 	}
59 59
 	bind_textdomain_codeset(WEBSITE_DOMAIN, 'UTF-8');
60 60
 	textdomain(WEBSITE_DOMAIN);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@
 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
Please login to merge, or discard this patch.
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.