Viewing file: clsSendReceive.php (14.28 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class sendreceive--------------------------
//--PK of sendreceive ::
// 1. tsr_id
include_once "../link/keyThai.php";
class sendreceive extends clsDB{
var $result;
var $tsr_id;
var $tsr_fr_node;
var $tsr_fr_node_date;
var $tsr_to_node;
var $tsr_to_node_date;
var $tsr_docid;
var $tsr_doc_url;
var $tsr_doc_chksum;
var $tsr_status;
var $tsr_id_send;
var $tsr_docgroup;
var $tsr_DrsID;
var $tsr_SendNew;
var $tsr_DocSubject;
var $tsr_DocNo;
var $tsr_DocDate;
var $tsr_DocFrom;
var $tsr_DocTo;
var $tsr_DocRef;
var $tsr_DocOther;
var $tsr_DslID;
var $tsr_DclID;
var $tsr_DocShortDesc;
var $tsr_PtID;
var $tsr_DlcID;
var $tsr_personId;
var $tsr_DtID;
var $tsr_docname;
var $tsr_receive;
var $tsr_receivedate;
var $tsr_DrsDocDueDate;
var $tsr_statusDocAtt;
function sendreceive(&$c){
$this->c=$c->c;
$this->DB=$c->db;
}
function Save(){
if ($this->status==1){
$sql = "insert into sendreceive values(
'".th2a($this->tsr_id)."',
'".th2a($this->tsr_fr_node)."',
'".th2a($this->tsr_fr_node_date)."',
'".th2a($this->tsr_to_node)."',
'".th2a($this->tsr_to_node_date)."',
'".th2a($this->tsr_docid)."',
'".th2a($this->tsr_doc_url)."',
'".th2a($this->tsr_doc_chksum)."',
'".th2a($this->tsr_status)."',
'".th2a($this->tsr_id_send)."',
'".th2a($this->tsr_docgroup)."',
'".th2a($this->tsr_DrsID)."',
'".th2a($this->tsr_SendNew)."',
'".th2a($this->tsr_DocSubject)."',
'".th2a($this->tsr_DocNo)."',
'".th2a($this->tsr_DocDate)."',
'".th2a($this->tsr_DocFrom)."',
'".th2a($this->tsr_DocTo)."',
'".th2a($this->tsr_DocRef)."',
'".th2a($this->tsr_DocOther)."',
'".th2a($this->tsr_DslID)."',
'".th2a($this->tsr_DclID)."',
'".th2a($this->tsr_DocShortDesc)."',
'".th2a($this->tsr_PtID)."',
'".th2a($this->tsr_DlcID)."',
'".th2a($this->tsr_personId)."',
'".th2a($this->tsr_DtID)."',
'".th2a($this->tsr_docname)."',
'".th2a($this->tsr_receive)."',
'".th2a($this->tsr_receivedate)."',
'".th2a($this->tsr_DrsDocDueDate)."',
'".th2a($this->tsr_statusDocAtt)."'
)";
}else {
$sql = "update sendreceive set
tsr_fr_node='".th2a($this->tsr_fr_node)."',
tsr_fr_node_date='".th2a($this->tsr_fr_node_date)."',
tsr_to_node='".th2a($this->tsr_to_node)."',
tsr_to_node_date='".th2a($this->tsr_to_node_date)."',
tsr_docid='".th2a($this->tsr_docid)."',
tsr_doc_url='".th2a($this->tsr_doc_url)."',
tsr_doc_chksum='".th2a($this->tsr_doc_chksum)."',
tsr_status='".th2a($this->tsr_status)."',
tsr_id_send='".th2a($this->tsr_id_send)."',
tsr_docgroup='".th2a($this->tsr_docgroup)."',
tsr_DrsID='".th2a($this->tsr_DrsID)."',
tsr_SendNew='".th2a($this->tsr_SendNew)."',
tsr_DocSubject='".th2a($this->tsr_DocSubject)."',
tsr_DocNo='".th2a($this->tsr_DocNo)."',
tsr_DocDate='".th2a($this->tsr_DocDate)."',
tsr_DocFrom='".th2a($this->tsr_DocFrom)."',
tsr_DocTo='".th2a($this->tsr_DocTo)."',
tsr_DocRef='".th2a($this->tsr_DocRef)."',
tsr_DocOther='".th2a($this->tsr_DocOther)."',
tsr_DslID='".th2a($this->tsr_DslID)."',
tsr_DclID='".th2a($this->tsr_DclID)."',
tsr_DocShortDesc='".th2a($this->tsr_DocShortDesc)."',
tsr_PtID='".th2a($this->tsr_PtID)."',
tsr_DlcID='".th2a($this->tsr_DlcID)."',
tsr_personId='".th2a($this->tsr_personId)."',
tsr_DtID='".th2a($this->tsr_DtID)."',
tsr_docname='".th2a($this->tsr_docname)."',
tsr_receive='".th2a($this->tsr_receive)."',
tsr_receivedate='".th2a($this->tsr_receivedate)."',
tsr_DrsDocDueDate='".th2a($this->tsr_DrsDocDueDate)."',
tsr_statusDocAtt='".th2a($this->tsr_statusDocAtt)."'
where tsr_id='".th2a($this->tsr_id)."'";
}
return $this->Dml($sql);
}
function Delete(){
$sql = "delete from sendreceive where tsr_id='$this->tsr_id'";
if ($this->conn->Execute($sql)){
return true;
}else{
$this->errNo=$this->conn->errNo;
$this->errDesc=$this->conn->errDesc;
return false;
}
}
function GetRecord(){
$numFields = $this->NumField();
$row = $this->GetResult();
if ($row){
for ($i=0; $i<$numFields; $i++){
eval("\$this->".mysql_field_name($this->rs, $i)."=\$row['".mysql_field_name($this->rs, $i)."'];");
}
return true;
}else{ // clear value of Member;
for ($i=0; $i<$numFields; $i++){
eval("\$this->".mysql_field_name($this->rs, $i)."='';");
}
return false;
}
}
function GetNextCode(){
//--ใช้เมธอดนี้เพื่อหาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
//--ต้องเป็นฟิลด์ที่ไม่ได้กำหนดรหัสเองทางจอภาพ
$cmd = "select max(tsr_id) as num from sendreceive";
$this->Open($cmd);
if($this->GetRecord())
return $this->num+1;
}
function RSsendreceive(){
$this->SetQuery("select * from sendreceive order by tsr_to_node_date");
}
function SearchByKey($key){
if ($this->SetQuery("select * from sendreceive where tsr_id='$key'")){
return 1;
}else {
return 0;
}
}
//***************************************************************************
//****************** You can add new methods below*********************************
//***************************************************************************
function SearchBytsr_docid($key){
if ($this->SetQuery("select * from sendreceive where tsr_docid ='$key'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_status($key){
if ($this->SetQuery("select * from sendreceive where tsr_status = '$key' order by tsr_to_node_date")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_docid_tsr_fr_node($xKey,$yKey){
if ($this->SetQuery("select * from sendreceive where tsr_docid = '$xKey' and tsr_fr_node='$yKey'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_docid_tsr_to_node_tsr_fr_node_date($xKey,$yKey,$zKey){
if ($this->SetQuery("select * from sendreceive where tsr_docid = '$xKey' and tsr_to_node='$yKey' and tsr_fr_node_date='$zKey'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_docid_tsr_to_node_tsr_fr_node_date2($xKey,$yKey,$zKey){
if ($this->SetQuery("select tsr_id from sendreceive where tsr_docid = '$xKey' and tsr_to_node='$yKey' and tsr_fr_node_date='$zKey'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_id_send($key){
if ($this->SetQuery("select * from sendreceive where tsr_id_send ='$key'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_DrsID($key){
if ($this->SetQuery("select * from sendreceive where tsr_DrsID ='$key'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_DrsID_tsr_to_node($xKey,$yKey){
if ($this->SetQuery("select * from sendreceive where tsr_DrsID ='$xKey' and tsr_to_node='$yKey'")){
return 1;
}else {
return 0;
}
}
function SearchBytsr_fr_node_tsr_DlcID_tsr_docgroup($xKey,$yKey,$zKey,$aKey){
//echo "select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date";
$this->SetQuery("select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date");
}
function SearchDocStatus($xKey,$yKey,$zKey,$aKey,$bKey){
//echo "select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date";
$this->SetQuery("select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status='$bKey' order by tsr_to_node_date");
}
function SearchDocStatusNoSend($xKey,$yKey,$zKey,$aKey,$bKey){
//echo "select count(tsr_id) as num from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status!='$bKey' order by tsr_fr_node_date desc";
$this->SetQuery("select count(tsr_id) as num from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status!='$bKey' order by tsr_fr_node_date desc");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchDocStatusNoSendlimit($xKey,$yKey,$zKey,$aKey,$bKey,$start,$pageSize){
//echo "select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date";
$this->SetQuery("select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status!='$bKey' order by tsr_fr_node_date desc limit $start, $pageSize");
}
function SearchDocStatusNoReceive($xKey,$bKey){
//echo "select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date";
$this->SetQuery("select * from sendreceive where tsr_to_node='$xKey' and tsr_status!='$bKey' order by tsr_to_node_date desc");
}
function SearchCountDocStatusSend($xKey,$yKey,$zKey,$aKey,$bKey){
//echo "select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date";
$this->SetQuery("select count(tsr_id) as num from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status='$bKey' order by tsr_to_node_date");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchCountDocStatusReceive($xKey,$bKey){
//echo "select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' order by tsr_to_node_date";
$this->SetQuery("select count(tsr_id) as num from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' order by tsr_to_node_date");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchCountDocStatusReceiveNumRow($xKey,$bKey,$monthe,$searchYear,$searchName,$searchNo){
if($searchName!="" && $searchNo==""){
$q="select count(tsr_id) as num from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocSubject like '%$searchName%'";
}else if($searchName=="" && $searchNo!=""){
$q="select count(tsr_id) as num from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocNo like '%$searchNo%'";
}else if($searchName!="" && $searchNo!=""){
$q="select count(tsr_id) as num from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocNo like '%$searchNo%' and tsr_DocSubject like '%$searchName%'";
}else{
$q="select count(tsr_id) as num from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%'";
}
$this->SetQuery($q);
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchDocStatuslimitSend($xKey,$yKey,$zKey,$aKey,$bKey,$start,$pageSize,$monthe,$searchYear,$searchName,$searchNo){
if($searchName!="" && $searchNo==""){
$q="select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocSubject like '%$searchName%' order by tsr_fr_node_date desc limit $start, $pageSize";
}else if($searchName=="" && $searchNo!=""){
$q="select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocNo like '%$searchNo%' order by tsr_fr_node_date desc limit $start, $pageSize";
}else if($searchName!="" && $searchNo!=""){
$q="select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocNo like '%$searchNo%' and tsr_DocSubject like '%$searchName%' order by tsr_fr_node_date desc limit $start, $pageSize";
}else{
$q="select * from sendreceive where tsr_fr_node='$xKey' and (tsr_DlcID='$yKey' || tsr_DlcID='$zKey') and tsr_docgroup='$aKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' order by tsr_fr_node_date desc limit $start, $pageSize";
}
$this->SetQuery($q);
}
function SearchDocStatuslimitReceive($xKey,$bKey,$start,$pageSize,$monthe,$searchYear,$searchName,$searchNo){
if($searchName!="" && $searchNo==""){
$q="select * from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocSubject like '%$searchName%' order by tsr_to_node_date desc limit $start, $pageSize";
}else if($searchName=="" && $searchNo!=""){
$q="select * from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocNo like '%$searchNo%' order by tsr_to_node_date desc limit $start, $pageSize";
}else if($searchName!="" && $searchNo!=""){
$q="select * from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' and tsr_DocNo like '%$searchNo%' and tsr_DocSubject like '%$searchName%' order by tsr_to_node_date desc limit $start, $pageSize";
}else{
$q="select * from sendreceive where tsr_to_node='$xKey' and tsr_status='$bKey' and tsr_fr_node_date like '$searchYear-$monthe-%' order by tsr_to_node_date desc limit $start, $pageSize";
}
$this->SetQuery($q);
}
function SearchBytsr_to_node($xKey){
//echo "select * from sendreceive where tsr_to_node='$xKey' order by tsr_to_node_date";
$this->SetQuery("select * from sendreceive where tsr_to_node='$xKey' order by tsr_to_node_date");
}
function SearchBytsr_id_send_tsr_fr_node($key,$yKey){
if ($this->SetQuery("select * from sendreceive where tsr_id_send ='$key' and tsr_fr_node='$yKey'")){
return 1;
}else {
return 0;
}
}
function SearchDocSend($xKey,$yKey){
//echo "select * from sendreceive where tsr_to_node='$xKey' order by tsr_to_node_date";
$this->SetQuery("select * from sendreceive where tsr_fr_node='$xKey' and tsr_docid='$yKey'");
}
function Deletetsr_id($xKey){
//echo "select * from sendreceive where tsr_to_node='$xKey' order by tsr_to_node_date";
$this->SetQuery("delete from sendreceive where tsr_id='$xKey'");
}
} //--End class sendreceive--
?>
|