getBranchCode()."','".$branch->getBranchName()."','".$branch->getCompanyCode()."','".$branch->getCompanyName()."','".$branch->getLicenseNo()."','".$branch->getAddress1()."','".$branch->getAddress2()."','".$branch->getCountry()."','".$branch->getTel()."','".$branch->getFax()."','".$branch->getEmail()."','".$branch->getDescription()."','".$branch->getLetterHead()."','".$branch->getBookingNo()."','".$branch->getReceiptNo()."',0,now(),now(),'".$branch->getModifiedBy()."')"; if (mysqli_query($conn,$sql)) { return TRUE; } else { return "Error: " . mysqli_error($conn); } } function selectBranch($branch_code){ global $conn; $branch=new Branch(); if (!$conn) { return "Connection Failed: " . mysqli_connect_error(); } $sql = "SELECT * FROM new_branch WHERE branch_code='$branch_code'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $branch->setBranchCode($row["branch_code"]); $branch->setBranchName($row["branch_name"]); $branch->setCompanyCode($row["company_code"]); $branch->setCompanyName($row["company_name"]); $branch->setLicenseNo($row["license_no"]); $branch->setAddress1($row["address1"]); $branch->setAddress2($row["address2"]); $branch->setCountry($row["country"]); $branch->setTel($row["tel"]); $branch->setFax($row["fax"]); $branch->setEmail($row["email"]); $branch->setDescription($row["description"]); $branch->setLetterHead($row["letter_head"]); $branch->setBookingNo($row["booking_no"]); $branch->setReceiptNo($row["receipt_no"]); $branch->setVoided($row["voided"]); $branch->setCreatedDate($row["created_on"]); $branch->setModifiedDate($row["modified_on"]); $branch->setModifiedBy($row["modified_by"]); }} return $branch; } function updateBranch($branch){ global $conn; if (!$conn) { return "Connection Failed: " . mysqli_connect_error(); } $sql = "UPDATE new_branch SET branch_code='".$branch->getBranchCode()."',branch_name='".$branch->getBranchName()."',company_code='".$branch->getCompanyCode()."', company_name='".$branch->getCompanyName()."',license_no='".$branch->getLicenseNo()."',address1='".$branch->getAddress1()."',address2='".$branch->getAddress2()."', country='".$branch->getCountry()."',tel='".$branch->getTel()."',fax='".$branch->getFax()."',email='".$branch->getEmail()."',description='".$branch->getDescription()."', letter_head='".$branch->getLetterHead()."',booking_no='".$branch->getBookingNo()."',receipt_no='".$branch->getReceiptNo()."',voided='".$branch->getVoided()."', modified_on=now(),modified_by='".$branch->getModifiedBy()."'"; ; if (mysqli_query($conn,$sql)) { return TRUE; } else { return "Error: " . mysqli_error($conn); } } function searchBranch($where){ global $conn; if (!$conn) { return "Connection Failed: " . mysqli_connect_error(); } $sql = "SELECT * FROM new_branch WHERE $where"; $result = mysqli_query($conn, $sql); $branches=array(); $i=0; if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $branch=new branch(); $branch->setBranchCode($row["branch_code"]); $branch->setBranchName($row["branch_name"]); $branch->setCompanyCode($row["company_code"]); $branch->setCompanyName($row["company_name"]); $branch->setLicenseNo($row["license_no"]); $branch->setAddress1($row["address1"]); $branch->setAddress2($row["address2"]); $branch->setCountry($row["country"]); $branch->setTel($row["tel"]); $branch->setFax($row["fax"]); $branch->setEmail($row["email"]); $branch->setDescription($row["description"]); $branch->setLetterHead($row["letter_head"]); $branch->setBookingNo($row["booking_no"]); $branch->setReceiptNo($row["receipt_no"]); $branch->setVoided($row["voided"]); $branch->setCreatedDate($row["created_on"]); $branch->setModifiedDate($row["modified_on"]); $branch->setModifiedBy($row["modified_by"]); $branches[$i]=$branch; $i=$i+1; }} return $branches; } function getLoginBranch($where){ global $conn; if (!$conn) { return "Connection Failed: " . mysqli_connect_error(); } $sql = "SELECT distinct branch_code,branch_name FROM new_branch WHERE voided=0"; $result = mysqli_query($conn, $sql); $branches=array(); $i=0; if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $branch=new branch(); $branch->setBranchCode($row["branch_code"]); $branch->setBranchName($row["branch_name"]); /* $branch->setCompanyCode($row["company_code"]); $branch->setCompanyName($row["company_name"]); $branch->setLicenseNo($row["license_no"]); $branch->setAddress1($row["address1"]); $branch->setAddress2($row["address2"]); $branch->setCountry($row["country"]); $branch->setTel($row["tel"]); $branch->setFax($row["fax"]); $branch->setEmail($row["email"]); $branch->setDescription($row["description"]); $branch->setLetterHead($row["letter_head"]); $branch->setBookingNo($row["booking_no"]); $branch->setReceiptNo($row["receipt_no"]); $branch->setVoided($row["voided"]); $branch->setCreatedDate($row["created_on"]); $branch->setModifiedDate($row["modified_on"]); $branch->setModifiedBy($row["modified_by"]); */ $branches[$i]=$branch; $i=$i+1; }} return $branches; } function selectBranchByCompany($branch_code,$cmp_code){ global $conn; $branch=new Branch(); if (!$conn) { return "Connection Failed: " . mysqli_connect_error(); } $sql = "SELECT * FROM new_branch WHERE branch_code='$branch_code' AND company_code='$cmp_code'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $branch->setBranchCode($row["branch_code"]); $branch->setBranchName($row["branch_name"]); $branch->setCompanyCode($row["company_code"]); $branch->setCompanyName($row["company_name"]); $branch->setLicenseNo($row["license_no"]); $branch->setAddress1($row["address1"]); $branch->setAddress2($row["address2"]); $branch->setCountry($row["country"]); $branch->setTel($row["tel"]); $branch->setFax($row["fax"]); $branch->setEmail($row["email"]); $branch->setDescription($row["description"]); $branch->setLetterHead($row["letter_head"]); $branch->setBookingNo($row["booking_no"]); $branch->setReceiptNo($row["receipt_no"]); $branch->setVoided($row["voided"]); $branch->setCreatedDate($row["created_on"]); $branch->setModifiedDate($row["modified_on"]); $branch->setModifiedBy($row["modified_by"]); }} return $branch; } function selectLetterHead($cmp,$branch){ global $conn; if (!$conn) { return "Connection Failed: " . mysqli_connect_error(); } $sql = "SELECT letter_head FROM new_branch WHERE branch_code='$branch' AND company_code='$cmp'"; $result = mysqli_query($conn, $sql); $letter_head=""; if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $letter_head=$row["letter_head"]; }} return $letter_head; } }