<?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "4321";
$dbname = "salecentral";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
mysqli_set_charset($conn,"utf8");
/* Database connection end */
// storing request (ie, get/post) global array to a variable
$requestData= $_REQUEST;
$columns = array(
// datatable column index => database column name
0 =>'ptype',
1 =>'date',
2 =>'name_partner',
3 =>'po_no',
4 => 'qt_no',
5 => 'com',
6 => 'file',
7 => 'Ename'
);
// getting total number records without any search
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee,po_detail where po.id_partner=partner.id_partner AND po.id_author=employee.Eid AND po.id=po_detail.id_po";
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows.
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee,po_detail where po.id_partner=partner.id_partner AND po.id_author=employee.Eid AND po.id=po_detail.id_po AND 1=1";
if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql.=" AND ( ptype LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR date LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR name_partner LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR po_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR qt_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR com LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR file LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR Ename LIKE '%".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result.
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
/* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$data = array();
while( $row=mysqli_fetch_array($query) ) { // preparing an array
$idPO= $row["idPO"];
$nestedData=array();
if($row['ptype']=='po') { $nestedData[] = "PO";}
if($row['ptype']=='ใบเคลม') { $nestedData[] = "ใบเคลม";}
if($row['com']=='CC') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/central.png' height='40px'/>";}
if($row['com']=='CL') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/clwheel.png' height='40px'/>";}
if($row['com']=='DS') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/dreamshop.png' height='40px'/>";}
list($Year,$month,$day) = explode("-",$row['date']);
$nestedData[] = (int)$day."/".(int)$month."/".($Year+543);
$nestedData[] = $row["po_no"];
if($row['qt_no']!= "ประวัติลูกค้า" && $row['qt_no']!= "ข้อมูลSale"){
if (strpos($row['qt_no'],'Rev'))
{ $nestedData[] = "<a class='example1' href='viewEdit$row[com].php?idx=$row[qt_no]'>$row[qt_no]</a>";}
else{ $nestedData[] = "<a class='example1' href='view$row[com].php?idx=$row[qt_no]'>$row[qt_no]</a>";}
} else { $nestedData[] = $row['qt_no'];}
$nestedData[] = $row["name_partner"];
list($name,$type) = explode(".",$row['file']);
if ($type =='pdf') { $nestedData[] = "<a class='example1' href='images/po/$row[file]'><img src='images/po/PDF-icon.png' align='left' width='60px'/></a>";}
else { $nestedData[] = "<a class='example1' href='preview.php?type=po&images=$row[file]'><img src='images/po/$row[file]' width='60px'/></a>";}
$nestedData[] = $row['Ename']." (".$row['Enname'].")";
$nestedData[] = "<a class='example1' href='checkEdit.php?idx=$idPO&po=po' target='_self'><img src='../images/edit.png' width='30' title='แก้ไข' border='0' ></a>";
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw.
"recordsTotal" => intval( $totalData ), // total number of records
"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
"data" => $data // total data array
);
echo json_encode($json_data); // send data as json format
?>
SELECT tb1.po_no, tb2.file AS file1, tb3.file AS file2 FROM po AS tb1 JOIN po_detail AS tb2 ON (tb2.id_po = tb1.id)
LEFT JOIN po_detail AS tb3 ON (tb3.id_po = tb1.id) AND tb3.id != tb2.id GROUP BY tb1.id
<?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "4321";
$dbname = "salecentral";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
mysqli_set_charset($conn,"utf8");
/* Database connection end */
// storing request (ie, get/post) global array to a variable
$requestData= $_REQUEST;
$columns = array(
// datatable column index => database column name
0 =>'ptype',
1 =>'date',
2 =>'name_partner',
3 =>'po_no',
4 => 'qt_no',
5 => 'com',
6 => 'file',
7 => 'Ename'
);
// getting total number records without any search
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee,po_detail where po.id_partner=partner.id_partner AND po.id_author=employee.Eid AND po.id=po_detail.id_po";
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows.
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee,po_detail where po.id_partner=partner.id_partner AND po.id_author=employee.Eid AND po.id=po_detail.id_po AND 1=1";
if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql.=" AND ( ptype LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR date LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR name_partner LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR po_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR qt_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR com LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR file LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR Ename LIKE '%".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result.
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
/* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$data = array();
while( $row=mysqli_fetch_array($query) ) { // preparing an array
$idPO= $row["idPO"];
$nestedData=array();
if($row['ptype']=='po') { $nestedData[] = "PO";}
if($row['ptype']=='ใบเคลม') { $nestedData[] = "ใบเคลม";}
if($row['com']=='CC') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/central.png' height='40px'/>";}
if($row['com']=='CL') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/clwheel.png' height='40px'/>";}
if($row['com']=='DS') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/dreamshop.png' height='40px'/>";}
list($Year,$month,$day) = explode("-",$row['date']);
$nestedData[] = (int)$day."/".(int)$month."/".($Year+543);
$nestedData[] = $row["po_no"];
if($row['qt_no']!= "ประวัติลูกค้า" && $row['qt_no']!= "ข้อมูลSale"){
if (strpos($row['qt_no'],'Rev'))
{ $nestedData[] = "<a class='example1' href='viewEdit$row[com].php?idx=$row[qt_no]'>$row[qt_no]</a>";}
else{ $nestedData[] = "<a class='example1' href='view$row[com].php?idx=$row[qt_no]'>$row[qt_no]</a>";}
} else { $nestedData[] = $row['qt_no'];}
$nestedData[] = $row["name_partner"];
list($name,$type) = explode(".",$row['file']);
if ($type =='pdf') { $nestedData[] = "<a class='example1' href='images/po/$row[file]'><img src='images/po/PDF-icon.png' align='left' width='60px'/></a>";}
else { $nestedData[] = "<a class='example1' href='preview.php?type=po&images=$row[file]'><img src='images/po/$row[file]' width='60px'/></a>";}
$nestedData[] = $row['Ename']." (".$row['Enname'].")";
$nestedData[] = "<a class='example1' href='checkEdit.php?idx=$idPO&po=po' target='_self'><img src='../images/edit.png' width='30' title='แก้ไข' border='0' ></a>";
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw.
"recordsTotal" => intval( $totalData ), // total number of records
"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
"data" => $data // total data array
);
echo json_encode($json_data); // send data as json format
?>
<?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "4321";
$dbname = "salecentral";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
mysqli_set_charset($conn,"utf8");
/* Database connection end */
// storing request (ie, get/post) global array to a variable
$requestData= $_REQUEST;
$columns = array(
// datatable column index => database column name
0 =>'ptype',
1 =>'date',
2 =>'name_partner',
3 =>'po_no',
4 => 'qt_no',
5 => 'com',
6 => 'file',
7 => 'Ename'
);
// getting total number records without any search
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee where po.id_partner=partner.id_partner AND po.id_author=employee.Eid ";
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData; // when there is no search parameter then total number rows = total number filtered rows.
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee where po.id_partner=partner.id_partner AND po.id_author=employee.Eid AND 1=1";
if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql.=" AND ( ptype LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR date LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR name_partner LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR po_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR qt_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR com LIKE '%".$requestData['search']['value']."%' ";
/*$sql.=" OR file LIKE '%".$requestData['search']['value']."%' ";*/
$sql.=" OR Ename LIKE '%".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result.
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
/* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$data = array();
while( $row=mysqli_fetch_array($query) ) { // preparing an array
$idPO= $row["idPO"];
$nestedData=array();
if($row['ptype']=='po') { $nestedData[] = "PO";}
if($row['ptype']=='ใบเคลม') { $nestedData[] = "ใบเคลม";}
if($row['com']=='CC') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/central.png' height='40px'/>";}
if($row['com']=='CL') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/clwheel.png' height='40px'/>";}
if($row['com']=='DS') { $nestedData[] = "<div style='color: red;opacity:0.0;'>$row[com]</div><img src='images/dreamshop.png' height='40px'/>";}
list($Year,$month,$day) = explode("-",$row['date']);
$nestedData[] = (int)$day."/".(int)$month."/".($Year+543);
$nestedData[] = $row["po_no"];
if($row['qt_no']!= "ประวัติลูกค้า" && $row['qt_no']!= "ข้อมูลSale"){
if (strpos($row['qt_no'],'Rev'))
{ $nestedData[] = "<a class='example1' href='viewEdit$row[com].php?idx=$row[qt_no]'>$row[qt_no]</a>";}
else{ $nestedData[] = "<a class='example1' href='view$row[com].php?idx=$row[qt_no]'>$row[qt_no]</a>";}
} else { $nestedData[] = $row['qt_no'];}
$nestedData[] = $row["name_partner"];
/*เพิ่ม*/
$sqlFile="SELECT * from po_detail where id_po='$idPO'";
$qFile= mysqli_query($conn, $sqlFile);
while ($rowFile = mysql_fetch_array($qFile)) {
$file = $rowFile['file'];
list($name,$type) = explode(".",$file);
if ($type =='pdf') { $nestedData[] = "<a class='example1' href='images/po/$file'><img src='images/po/PDF-icon.png' align='left' width='60px'/></a>";}
else { $nestedData[] = "<a class='example1' href='preview.php?type=po&images=$file'><img src='images/po/$file' width='60px'/></a>";}
}
$nestedData[] = $row['Ename']." (".$row['Enname'].")";
$nestedData[] = "<a class='example1' href='checkEdit.php?idx=$idPO&po=po' target='_self'><img src='../images/edit.png' width='30' title='แก้ไข' border='0' ></a>";
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval( $requestData['draw'] ), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw.
"recordsTotal" => intval( $totalData ), // total number of records
"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
"data" => $data // total data array
);
echo json_encode($json_data); // send data as json format
?>
$sql = "SELECT po.id As idPO,date, name_partner, po_no, qt_no, com,Ename,Enname,file,ptype ";
$sql.=" FROM po,partner,employee where po.id_partner=partner.id_partner AND po.id_author=employee.Eid AND 1=1";
if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql.=" AND ( ptype LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR date LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR name_partner LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR po_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR qt_no LIKE '%".$requestData['search']['value']."%' ";
$sql.=" OR com LIKE '%".$requestData['search']['value']."%' ";
/*$sql.=" OR file LIKE '%".$requestData['search']['value']."%' ";*/
$sql.=" OR Ename LIKE '%".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result.
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
/* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees");