Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/erp/models/ |
<?php
//if (!class_exists($erpModel)) {
require_once __DIR__."/erp_model.php";
//}
class iwdModel extends erpModel {
public function __construct() {
// mysql connection using PDO
try {
$this->pdo = new PDO('mysql:host=' .DB_SERVER. ';dbname=' .DB_NAME. ';charset=utf8', DB_USER, DB_PASSWD, $options);
$this->pdo->query("use erp_iwd");
} catch (PDOException $e) {
die("Error!: " . $e->getMessage());
}
}
public function __destruct() {
//print mysql_error();
$this->dbStmt = null;
$this->pdo = null;
}
//***********************************************************************
//* iwd fee head functions *
//***********************************************************************
function saveFeehead($feeheadCode,$feeheadName,$accountType,$paymentTerm) {
if ($this->pdo->query("SELECT * FROM " .$this->tableID. " WHERE feeheadID=" .$this->tupleID)->rowCount()) {
$this->sqlStmt = "UPDATE " .$this->tableID. " SET feeheadCode='$feeheadCode',feeheadName='$feeheadName',accountType=$accountType,paymentTerm=$paymentTerm
WHERE feeheadID=" .$this->tupleID;
$this->pdo->exec($this->sqlStmt);
} else{
$this->sqlStmt = "INSERT INTO " .$this->tableID. "(feeheadCode,feeheadName,accountType,paymentTerm)
value('$feeheadCode','$feeheadName',$accountType,$paymentTerm)";
$this->pdo->exec($this->sqlStmt);
$this->tupleID = $this->pdo->lastInsertId();
}
}
function deleteFeehead() {
$this->sqlStmt = "DELETE FROM " .$this->tableID. " WHERE feeheadID=" .$this->tupleID;
$this->pdo->exec($this->sqlStmt);
}
function getFeehead($feeheadID=0) {
if ($feeheadID) {
$this->dbStmt = $this->pdo->query("SELECT * FROM erp_iwd.iwd_feeheads WHERE feeheadID=$feeheadID");
return $this->dbStmt->fetch(PDO::FETCH_ASSOC);
}
}
function listFeeheads() {
$this->dbStmt = $this->pdo->query("SELECT * FROM erp_iwd.iwd_feeheads ORDER BY accountType,paymentTerm,feeheadName");
return $this->dbStmt->fetchAll(PDO::FETCH_ASSOC);
}
function selectFeehead() {
$this->dbStmt = $this->pdo->query("SELECT * FROM erp_iwd.iwd_feeheads WHERE status='Enabled' ORDER BY feeheadName");
return $this->dbStmt->fetchAll(PDO::FETCH_ASSOC);
}
}
?>