芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/socialsolargreens.pk/controller/third_level_controller.php
con, $query); return $data; } public function firstlevel_dropdown($firstlevel) { $query= "SELECT * FROM `socialsolargreen`.`firstlevel` WHERE Headid = '".$firstlevel."' "; $qd = mysqli_query($this->con, $query); if(mysqli_num_rows($qd) > 0){ $optoin = ''; while($data = mysqli_fetch_assoc($qd)){ $optoin .= '
'.$data['AccountTitle'].'
'; } return $optoin; }else{ return '
Select
'; } die; } public function secondlevel_dropdown($secondlevel) { $query= "SELECT * FROM `socialsolargreen`.`Secondlevel` WHERE SubHeadid = '".$secondlevel."' "; $qd = mysqli_query($this->con, $query); if(mysqli_num_rows($qd) > 0){ $optoin = ''; while($data = mysqli_fetch_assoc($qd)){ $optoin .= '
'.$data['AccountTitle'].'
'; } return $optoin; }else{ return '
Select
'; } die; } public function Save($post_data = '') { global $dbobj; if (empty($post_data['ThirdLevel_Id'])) { $query = "Select Count(*) as count from ThirdLevel where AccountTitle = '".$post_data['ThirdLevel_AccountTitle']."'"; if ($result = mysqli_query($this->con, $query)) { $count = $result -> fetch_assoc(); }else{ return "Error Code [351] : " . mysqli_error($this->con); die; } // print_r($count['count']); // die; // print_r($post_data); // die; if ($count['count'] == 0) { $AccountType_query = "SELECT AccountTitle FROM Secondlevel WHERE AccountNo = '".$post_data['ThirdLevel_SecondHeadid']."'"; if ($AccountType_query_data = mysqli_query($this->con, $AccountType_query)) { $AccountType = $AccountType_query_data -> fetch_assoc();; } else{ return "Error Code [411] : " . mysqli_error($this->con); die; } if ($post_data['Thirdlevel_Headid'] == 1) { // print_r($post_data['Thirdlevel_Headid']); // die; $SecondLevel_AccountNo = "SELECT IFNULL(MAX(AccountNo), 0) as account_no FROM ThirdLevel where Headid = '".$post_data['Thirdlevel_Headid']."'"; if (mysqli_query($this->con, $SecondLevel_AccountNo)) { $SecondLevel_AccountNo_data_values = mysqli_query($this->con, $SecondLevel_AccountNo)->fetch_assoc(); } else{ return "Error Code [411] : " . mysqli_error($this->con); die; } // print_r($SecondLevel_AccountNo_data_values['account_no']); // die; if ($SecondLevel_AccountNo_data_values['account_no'] == 0) { $final_acc = "1100001"; } else { $final_acc = $SecondLevel_AccountNo_data_values['account_no'] + 1; } } if ($post_data['Thirdlevel_Headid'] == 2) { $SecondLevel_AccountNo = "SELECT IFNULL(MAX(AccountNo), 0) as account_no FROM ThirdLevel where Headid = '2'"; if (mysqli_query($this->con, $SecondLevel_AccountNo)) { $SecondLevel_AccountNo_data_values = mysqli_query($this->con, $SecondLevel_AccountNo)->fetch_assoc(); } else{ return "Error Code [411] : " . mysqli_error($this->con); die; } // print_r($SecondLevel_AccountNo_data_values['account_no']); // die; if ($SecondLevel_AccountNo_data_values['account_no'] == 0) { $final_acc = "2200001"; } else { $final_acc = $SecondLevel_AccountNo_data_values['account_no'] + 1; } } if ($post_data['Thirdlevel_Headid'] == 3) { $SecondLevel_AccountNo = "SELECT IFNULL(MAX(AccountNo), 0) as account_no FROM ThirdLevel where Headid = '3'"; if (mysqli_query($this->con, $SecondLevel_AccountNo)) { $SecondLevel_AccountNo_data_values = mysqli_query($this->con, $SecondLevel_AccountNo)->fetch_assoc(); } else{ return "Error Code [411] : " . mysqli_error($this->con); die; } // print_r($SecondLevel_AccountNo_data_values['account_no']); // die; if ($SecondLevel_AccountNo_data_values['account_no'] == 0) { $final_acc = "3300001"; } else { $final_acc = $SecondLevel_AccountNo_data_values['account_no'] + 1; } } if ($post_data['Thirdlevel_Headid'] == 4) { $SecondLevel_AccountNo = "SELECT IFNULL(MAX(AccountNo), 0) as account_no FROM ThirdLevel where Headid = '4'"; if (mysqli_query($this->con, $SecondLevel_AccountNo)) { $SecondLevel_AccountNo_data_values = mysqli_query($this->con, $SecondLevel_AccountNo)->fetch_assoc(); } else{ return "Error Code [411] : " . mysqli_error($this->con); die; } // print_r($SecondLevel_AccountNo_data_values['account_no']); // die; if ($SecondLevel_AccountNo_data_values['account_no'] == 0) { $final_acc = "4400001"; } else { $final_acc = $SecondLevel_AccountNo_data_values['account_no'] + 1; } } if ($post_data['Thirdlevel_Headid'] == 5) { $SecondLevel_AccountNo = "SELECT IFNULL(MAX(AccountNo), 0) as account_no FROM ThirdLevel where Headid = '5'"; if (mysqli_query($this->con, $SecondLevel_AccountNo)) { $SecondLevel_AccountNo_data_values = mysqli_query($this->con, $SecondLevel_AccountNo)->fetch_assoc(); } else{ return "Error Code [411] : " . mysqli_error($this->con); die; } // print_r($SecondLevel_AccountNo_data_values['account_no']); // die; if ($SecondLevel_AccountNo_data_values['account_no'] == 0) { $final_acc = "5500001"; } else { $final_acc = $SecondLevel_AccountNo_data_values['account_no'] + 1; } } $q2 = "insert into ThirdLevel (AccountNo, Headid, SubHeadid, SecondHeadid, AccountTitle, AccountType, Dr, Cr) values('".$final_acc."','".$post_data['Thirdlevel_Headid']."','".$post_data['ThirdLevel_SubHeadid']."','".$post_data['ThirdLevel_SecondHeadid']."',N'".$post_data['ThirdLevel_AccountTitle']."',N'".$AccountType['AccountTitle']."','0','0')"; if (mysqli_query($this->con, $q2)) { return 'Third Level Account Register Successfully'; } else{ return "Error Code [321] : " . mysqli_error($this->con); } } else { return "This Account Already Exists"; die; } } else { $update = "UPDATE ThirdLevel SET AccountTitle ='".ltrim($post_data['ThirdLevel_AccountTitle'])."' WHERE Id='".$post_data['ThirdLevel_Id']."' ;"; $update .= "UPDATE Supplier SET Name ='".ltrim($post_data['ThirdLevel_AccountTitle'])."' WHERE AccountNo='".$post_data['ThirdLevel_AccountNo']."' ;"; $update .= "UPDATE Customer SET Name ='".ltrim($post_data['ThirdLevel_AccountTitle'])."' WHERE AccountNo='".$post_data['ThirdLevel_AccountNo']."'"; // print_r($update); // die; /* execute multi query */ // $mysqli->multi_query($update); // do { // $result = $mysqli->store_result(); /* store the result set in PHP */ // if ($result = $mysqli->store_result()) { // while ($row = $result->fetch_row()) { // printf("%s\n", $row[0]); // } // } // /* print divider */ // if ($mysqli->more_results()) { // printf("-----------------\n"); // } // } while ($mysqli->next_result()); // execute query - $result is false if the first query failed $result = mysqli_multi_query($this->con, $update); if ($result) { do { // grab the result of the next query if (($result = mysqli_store_result($this->con)) === false && mysqli_error($this->con) != '') { return "Error Code [571] : " . mysqli_error($this->con); } // grab the result of the next query } while (mysqli_more_results($this->con) && mysqli_next_result($this->con)); // while there are more results } else { return "Error Code [371] : " . mysqli_error($this->con); } // if (mysqli_multi_query($this->con, $update)) { // return 'Third Level Account Update Successfully'; // } else{ // return "Error Code [371] : " . mysqli_error($this->con); // } } // die; } public function Edit($AccountNo = ''){ if(!empty($AccountNo)){ $SecondLevel = "select * from ThirdLevel where AccountNo = '$AccountNo'"; $d = mysqli_query($this->con, $SecondLevel); // print_r($d); // die; if ($d->num_rows > 0) { $data = mysqli_fetch_assoc($d); return $data; } else{ return "Error Code [521] : " . mysqli_error($this->con); } } } public function Delete($AccountNo = ''){ global $dbobj; $SecondLevel = "Delete from SecondLevel where AccountNo = $AccountNo"; if (mysqli_query($this->con, $SecondLevel)) { return 'SecondLevel Deleted Success'; } else{ return "Error Code [245] : " . mysqli_error($this->con); } } } ?>