芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/socialsolargreens.pk/controller/supplier_controller.php
con,$Supplier); return $data; } public function Save($Supplier) { // print_r($Supplier); // die; if (empty($Supplier['Id'])) { // Set Third Leavel $account_no1=''; $ThirdLevel_AccountNo = $this->select_query("select IFNULL(MAX(AccountNo), 0) as account_no from ThirdLevel where Headid = '2'"); if ($ThirdLevel_AccountNo[0]['account_no'] == 0) { $account_no1 = "2100001"; } else { $account_no1 = $ThirdLevel_AccountNo[0]['account_no'] + 1; } $Supplier_AccountNo = $account_no1; // isert third leavel $q = "Insert into ThirdLevel (AccountNo, Headid, SubHeadid, SecondHeadid, AccountTitle, AccountType, Dr, Cr) VALUES (".$account_no1. ",2,2001,2000002,N'".$Supplier['Name']."','Supplier',0,0)"; if (mysqli_query($this->con, $q)) { $q2 = "INSERT INTO supplier (AccountNo,Name, CompanyName, Phone, Address, Cnic) VALUES ('".$Supplier_AccountNo."','".$Supplier['Name']."', '".$Supplier['CompanyName']."', '".$Supplier['Phone']."', '".$Supplier['Address']."', '".$Supplier['Cnic']."')"; if (mysqli_query($this->con, $q2)) { return 'Success'; } else{ return "Error Code [321] : " . mysqli_error($this->con); } } else { return "Error Code [132]: " . mysqli_error($this->con); } } else { $q2 = "UPDATE `socialsolargreen`.`supplier` SET `Name`='".$Supplier['Name']."', `CompanyName`='".$Supplier['CompanyName']."', `Phone`='".$Supplier['Phone']."', `Address`='".$Supplier['Address']."', `Cnic`='".$Supplier['Cnic']."' WHERE `Id`='".$Supplier['Id']."'"; if (mysqli_query($this->con, $q2)) { // return json_encode($Supplier); return 'Success'; } else{ return "Error Code [421] : " . mysqli_error($this->con); } } } public function Edit($Id = ''){ if(!empty($Id)){ $Supplier = "select * from Supplier Where id = $Id"; $d = mysqli_query($this->con, $Supplier); // print_r($d); 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; $Supplier = "Delete from Supplier where Id = $AccountNo"; if (mysqli_query($this->con, $Supplier)) { return 'Supplier Deleted Success'; } else{ return "Error Code [245] : " . mysqli_error($this->con); } } } ?>