Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partner information changes #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions PartnerInformation/PartnerInformation.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<?php
G::LoadClass("plugin");

if(!empty ($_POST['s_val'])){
require_once ("PartnerInformation/classes/class.dashletPartnerInformation.php");
if(!empty ($_POST['s_val'])&& empty ($_POST['d_val']) )
{

require_once("PartnerInformation/classes/class.dashletPartnerInformation.php");
$call = new dashletPartnerInformation();
$call->render($_POST['s_val']);

}

if(!empty ($_POST['d_val'])){

require_once ("PartnerInformation/classes/class.dashletPartnerInformation.php");
$call = new dashletPartnerInformation();
$call->renderDetails($_POST['d_val']);

}

class PartnerInformationPlugin extends PMPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
require_once ("classes/interfaces/dashletInterface.php");





class dashletPartnerInformation implements DashletInterface
{
const version = '1.0';
Expand Down Expand Up @@ -73,7 +70,7 @@ public static function getAdditionalFields($className)

public static function getXTemplate($className)
{
return "<iframe src=\"{" . "page" . "}?DAS_INS_UID={" . "id" . "}\" width=\"{" . "width" . "}\" height=\"207\" frameborder=\"0\"></iframe>";
return "<iframe src=\"{" . "page" . "}?DAS_INS_UID={" . "id" . "}\" width=\"{" . "width" . "}\" height=\"400\" frameborder=\"0\"></iframe>";
}

public function setup($config)
Expand All @@ -88,33 +85,75 @@ public function render($val= null , $width = 300)
$stmt = $cnn->createStatement();

if(!empty($_POST)) {

$val = $_POST['s_val'];
}

$arrayUser = array();

$sql = "SELECT USR.USR_USERNAME, USR.USR_FIRSTNAME, USR.USR_LASTNAME, USR.USR_STATUS
FROM USERS AS USR
/*$sql = "SELECT USR.USR_USERNAME, USR.USR_FIRSTNAME, USR.USR_LASTNAME, USR.USR_STATUS
FROM USERS AS USR
WHERE USR.USR_ROLE = '" . $this->role . "'
ORDER BY USR.USR_USERNAME ASC";
ORDER BY USR.USR_USERNAME ASC"; */

$sql = "SELECT PARTNER_NAME, TYPE_OF_PARTNER, ADDRESS, DATE_OF_MEETING, SUMMARY_OF_MEETING, CONTACT_NUMBER, CONTACT_PERSON, EMAIL_ID FROM PMT_PARTNERINFO WHERE Partner_name LIKE '$val%' ORDER BY app_number DESC LIMIT 1";
//$sql = "SELECT PARTNER_NAME, TYPE_OF_PARTNER, ADDRESS, DATE_OF_MEETING, SUMMARY_OF_MEETING, CONTACT_NUMBER, CONTACT_PERSON, EMAIL_ID FROM PMT_PARTNERINFO WHERE Partner_name LIKE '$val%' ORDER BY app_number DESC LIMIT 1";

$sql = "SELECT DISTINCT(PARTNER_NAME) as PARTNER_NAME FROM PMT_PARTNERINFO WHERE Partner_name LIKE '$val%' ORDER BY app_number DESC";

$rsSQL = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
while ($rsSQL->next()) {
$row = $rsSQL->getRow();

//$arrayUser[] = array("userName" => $row["USR_USERNAME"], "fullName" => $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"], "status" => $row["USR_STATUS"]);

$arrayUser[] = array("partnername" => $row["PARTNER_NAME"], "partnertype" => $row["TYPE_OF_PARTNER"] , "address" => $row["ADDRESS"], "meetingdate" => $row["DATE_OF_MEETING"], "summary" => $row["SUMMARY_OF_MEETING"], "cnumber" => $row["CONTACT_NUMBER"], "cperson" => $row["CONTACT_PERSON"], "email" => $row["EMAIL_ID"] );
// $arrayUser[] = array("partnername" => $row["PARTNER_NAME"], "partnertype" => $row["TYPE_OF_PARTNER"] , "address" => $row["ADDRESS"], "meetingdate" => $row["DATE_OF_MEETING"], "summary" => $row["SUMMARY_OF_MEETING"], "cnumber" => $row["CONTACT_NUMBER"], "cperson" => $row["CONTACT_PERSON"], "email" => $row["EMAIL_ID"] );

$arrayUser[] = array("partnername" => $row["PARTNER_NAME"]);

}

///////
$dashletView = new dashletPartnerInformationView($arrayUser, $this->note);
$dashletView->templatePrint();
}



public function renderDetails($val= null , $width = 300)
{

$cnn = Propel::getConnection("workflow");
$stmt = $cnn->createStatement();


if(!empty($_POST)) {
$val = $_POST['d_val'];
}

$arrayUser = array();

$sql = "SELECT USR.USR_USERNAME, USR.USR_FIRSTNAME, USR.USR_LASTNAME, USR.USR_STATUS
FROM USERS AS USR
WHERE USR.USR_ROLE = '" . $this->role . "'
ORDER BY USR.USR_USERNAME ASC";


$sql = "SELECT PARTNER_NAME, TYPE_OF_PARTNER, ADDRESS, DATE_OF_MEETING, SUMMARY_OF_MEETING, CONTACT_NUMBER, CONTACT_PERSON, EMAIL_ID FROM PMT_PARTNERINFO WHERE Partner_name LIKE '%$val%' ORDER BY app_number DESC LIMIT 1";

$rsSQL = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
while ($rsSQL->next()) {
$row = $rsSQL->getRow();

$arrayUser[] = array("partnername" => $row["PARTNER_NAME"], "partnertype" => $row["TYPE_OF_PARTNER"] , "address" => $row["ADDRESS"], "meetingdate" => $row["DATE_OF_MEETING"], "summary" => $row["SUMMARY_OF_MEETING"], "cnumber" => $row["CONTACT_NUMBER"], "cperson" => $row["CONTACT_PERSON"], "email" => $row["EMAIL_ID"] );

}

///////
$dashletView = new dashletPartnerInformationViewDetails($arrayUser, $this->note);
$dashletView->templatePrintD();
}


}


Expand Down Expand Up @@ -145,7 +184,7 @@ public function templateRender()
{
$this->smarty->assign("user", $this->user);
$this->smarty->assign("note", $this->note);

$this->smarty->assign("item", $this->user);
return ($this->smarty->fetch($this->smarty->templateFile));
}

Expand All @@ -155,4 +194,42 @@ public function templatePrint()
exit(0);
}
}

class dashletPartnerInformationViewDetails extends Smarty
{
private $smarty;

private $user;
private $note;

public function __construct($u, $n)
{
$this->user = $u;
$this->note = $n;

$this->smarty = new Smarty();
$this->smarty->compile_dir = PATH_SMARTY_C;
$this->smarty->cache_dir = PATH_SMARTY_CACHE;
$this->smarty->config_dir = PATH_THIRDPARTY . "smarty/configs";
$this->smarty->caching = false;
$this->smarty->templateFileD = PATH_PLUGINS . "PartnerInformation" . PATH_SEP . "views" . PATH_SEP . "dashletPartnerInfo.html";
}

public function templateRenderD()
{
$this->smarty->assign("user", $this->user);
$this->smarty->assign("note", $this->note);

return ($this->smarty->fetch($this->smarty->templateFileD));
}

public function templatePrintD()
{
echo $this->templateRenderD();
exit(0);
}
}



?>
208 changes: 208 additions & 0 deletions PartnerInformation/PartnerInformation/views/dashletPartnerInfo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title></title>

{literal}
<script type="text/javascript">


function printDiv(divName) {

var printContents = document.getElementById(divName).innerHTML;
w=window.open();
w.document.write(printContents);
w.print();
w.close();
}

function operation(id){

var val = document.getElementById("search").value;
callAjaxxx(val);
}

function callAjaxxx(val){
console.log(val);
var https = new XMLHttpRequest();
var url = "../PartnerInformation/PartnerInformation";
var params = "s_val="+val;
https.open("POST", url, true);
https.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
https.onreadystatechange = function() {
if(https.readyState == 4 && https.status == 200) {
var container = document.getElementById("maindiv");
container.innerHTML = "";
container.innerHTML = https.responseText;
document.getElementById("search").value = val ;
console.log(url);

}
}
https.send(params);
}


</script>
<style type="text/css">
body {
margin: 0;
padding: 0;

background: #FFFFFF;
color: #000000;
font: 85% arial, verdana, helvetica, sans-serif;
}

.dataGrid {
border: 1px solid #48627A;
padding: 0;

width: 99%;
height: 100%;

background: #FFFFFF;
text-align: left;
}

.dataGridTitle{
border: 1px solid #0D1115;

padding-top: 1px;
padding-right: 3px;
padding-bottom: 1px;
padding-left: 3px;

background: #48627A;
color: #FFFFFF;
text-align: center;

font: bold 0.8em verdana, arial, helvetica, sans-serif;
}

.dataGridElement{
padding-top: 1px;
padding-right: 3px;
padding-bottom:1px;
padding-left: 3px;

background: #E8EAEA;
color: #000000;

font: 0.8em verdana, arial, helvetica, sans-serif;
}
.td{
width:130px;
}

</style>
{/literal}
</head>
<body>

<!--<div class="dataGrid">
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<th class="dataGridTitle">User name</th>
<th class="dataGridTitle">Full name</th>
<th class="dataGridTitle">Status</th>
</tr>

{foreach from=$user item=item}
<tr>
<td class="dataGridElement">{$item.userName}</td>
<td class="dataGridElement">{$item.fullName}</td>
<td class="dataGridElement">{$item.status}</td>
</tr>
{/foreach}
</table>
</div>

<div style="margin-top: 0.25em;"><strong>Note: </strong>{$note}</div> -->

<div id = "maindiv">
<div id = "searchDiv" style="margin-top:10px;margin-bottom:10px;margin-left:10px;" >
<input type='text' id='search' required >
<input id='btnSearch' onclick="operation(this.id)" type ="button" value='Search' >

</div>

<form>

<div id="print">
<div class="dataGrid" style="margin-top:10px;margin-bottom:10px;margin-left:10px;" >
<h1 style="margin-top:10px;margin-bottom:10px;margin-left:10px;" >Partner Details</h1>
<table style="table-layout:fixed; margin-top:10px;margin-bottom:10px;margin-left:10px;" >
<tr>
<td class = "td" ><label for="username">Name</label>
</td>
<td><label for="username">{$item.partnername}</label>
</td>
</tr>

<tr>
<td class = "td" ><label for="pwd">Type</label>
</td>
<td><label for="pwd">{$item.partnertype}</label>
</td>
</tr>

<tr>
<td class = "td" ><label for="surname">Address</label>
</td>
<td><label for="surname">{$item.address}</label>
</td>
</tr>

<tr>
<td class = "td" ><label for="surname">Meeting Date</label>
</td>
<td><label for="surname">{$item.meetingdate}</label>
</td>
</tr>

<tr>
<td class = "td" ><label for="surname">Summary</label>
</td>
<td><label for="surname">{$item.summary}</label>
</td>
</tr>

<tr>
<td class = "td" ><label for="surname">Contact Number</label>
</td>
<td><label for="surname">{$item.cnumber}</label>
</td>
</tr>


<tr>
<td class = "td" ><label for="surname">Contact Person</label>
</td>
<td><label for="surname">{$item.cperson}</label>
</td>
</tr>

<tr>
<td class = "td" ><label for="surname">Email</label>
</td>
<td><label for="surname">{$item.email}</label>
</td>
</tr>
</table>


</form>


</div>
</div>


<input type="button" onclick = "printDiv('print')" value="Print" style="margin-top:10px;margin-bottom:10px;margin-left:10px;" />
</div>
</body>
</html>
Loading