Skip to content
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
67 changes: 33 additions & 34 deletions admin/phpfiles/manageproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,20 @@ function delete_confirm(id)
var current_id = $('#product_id').val();
var product_name = $('#product').val();

var url = '';

if(current_id<=0)
{
url = "module=Product&mode=NewProduct&name="+product_name;
}
else
{
url = "module=Product&mode=NewProduct&id="+current_id+"&name="+product_name;
}
//alert(url);
var postData = {
module: "Product",
mode: "NewProduct",
name: product_name
};
if (current_id) {
postData.id = current_id;
}

$.ajax({
type: "GET",
type: "POST",
url: "ajax.php",
data: url,
dataType: "json",
data: postData,
success: function(msg){
//alert( "Data Saved: " + msg );
window.location.reload();
Expand Down Expand Up @@ -175,7 +173,7 @@ function activate_confirm(id)
<table cellspacing="0" cellpadding="5" align="center" width="95%" id="product-table">
<tr height="60" bgcolor="#FFFFFF">
<td colspan="6" align="center" >
<form method="get" action="">
<form method="post" action="">
<input type="hidden" name="module" value="Product" />
<input type="hidden" name="mode" value="ManageProduct" />
<label><strong>Search Product by Name</strong>&nbsp;</label>
Expand Down Expand Up @@ -277,10 +275,10 @@ function activate_confirm(id)
$sql1 = "SELECT * FROM vendor WHERE vendor_id='".$row['vendor_id']."'";
$res1 = mysqli_query($conn, $sql1);
$row1 = mysqli_fetch_array($res1);
$url = $row1['www'];
$www = $row1['www'];

if (strpos($url, '://') === FALSE && $url ) {
$url = 'http://'.$url;
if (strpos($www, '://') === FALSE && $www ) {
$www = 'http://'.$www;
}

if(($j%2)==0)
Expand All @@ -290,7 +288,7 @@ function activate_confirm(id)
?>
<tr bgcolor="<?php echo $bgcolor; ?>">
<td><?php echo $row1['vendor_name']; ?></td>
<td><a href="<?php echo $url; ?>" target="_blank"><?php echo $url; ?></a></td>
<td><a href="<?php echo $www; ?>" target="_blank"><?php echo $www; ?></a></td>
<td><?php echo $row['product_name']; ?></td>
<td align="center">
<?php
Expand Down Expand Up @@ -390,7 +388,10 @@ function reloadproduct(){
var review_date = $("#review_date").val();
var www = $("#www").val();
var notes = $("#notes").val();
var mtco = $("#mtxo").val(); console.log("MTXO::>>%s",mtco);
var mtco = $("#mtxo").val();

console.log("URL::>>%s",www);
console.log("MTCO::>>%s",mtco);

//review_date = $.datepicker.formatDate('yy-dd-mm', review_date);

Expand Down Expand Up @@ -457,30 +458,28 @@ function reloadproduct(){
var url = "phpfiles/saveproductschanges.php";
//var post_data_obj = {id:pid, prod_name:prod_name, vendor_id:vendor_id, review_date:review_date, notes:notes}; //, 'procost[]':procost, 'promarket[]':promarket};
var post_data = {
id:pid,
id:pid, mtco:mtco, notes:notes, www:www,
prod_name:product_name,
vendor_id:vendor_id,
review_date:review_date,
www:www,
notes:notes,
mtco:mtco,
'procost[]':procost,
'promarket[]':promarket
}; //, 'procost[]':procost, 'promarket[]':promarket};
var post_data_qry = $.param(post_data);
// show hourglass while saving
$(document.body).css({'cursor' : 'wait'});
// get DOM element for button
var buttonDomElement = evt.target;
// Disable the button
$(buttonDomElement).attr('disabled', true);

$.post("phpfiles/saveproductschanges.php", post_data,
var post_data_qry = $.param(post_data);
// show hourglass while saving
$(document.body).css({'cursor' : 'wait'});
// get DOM element for button
var buttonDomElement = evt.target;
// Disable the button
$(buttonDomElement).attr('disabled', true);
console.log('posturl:', url);
console.log('postdata:', post_data);
$.post(url, post_data,
function(response) {
$('#product-dialog').dialog( "close" );
$("#btn_Product").click();
// show hourglass while saving
$(document.body).css({'cursor' : 'default'});
$(document.body).css({'cursor' : 'default'});
});

},
Expand Down Expand Up @@ -574,7 +573,7 @@ function(response) {
var buttonDomElement = evt.target;
// Disable the button
$(buttonDomElement).attr('disabled', true);
console.log('post data:', post_data);
//console.log('post data:', $.post_data);
$.post(url,{'procost[]':procost,'promarket[]':promarket}, function(response) {
/*$("#save-result").html(response);*/
$('#new-product-dialog').dialog( "close" );
Expand Down
15 changes: 8 additions & 7 deletions admin/phpfiles/productdetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$productname = $row['product_name'];
$vendor_id = $row['vendor_id'];
$review_date = (''==$row['review_date']||empty($row['review_date']))?'':date('m/d/Y', strtotime($row['review_date']));
$www = $row['www'];
$notes = $row['notes'];
$mtco = $row['mtco'];
$www = $row['www'];
$notes = $row['notes'];
$mtco = $row['mtco'];
}
mysqli_free_result($res);
} else {
Expand Down Expand Up @@ -193,7 +193,7 @@ function checkBrokenLinks($url) {
<tr><td colspan="6">

<label>Multi-tenant Cloud Only:
<input type="checkbox" id="mtxo" name="mtxo" onclick="$(this).attr('value', this.checked ? 1 : 0)" \
<input type="checkbox" id="mtxo" name="mtxo" value="<?php echo $mtco;?>" onclick="$(this).attr('value', this.checked ? 1 : 0)" \
<?php echo ($mtco==1)?"checked":"";?> />
</label>
</td></tr>
Expand Down Expand Up @@ -244,14 +244,15 @@ function checkBrokenLinks($url) {
<script>

var isCheckbox = document.querySelector('#mtxo');

//$("#mtxo").val()=isCheckbox.checked ? '1' : '0';
console.log("mtc0:%s", $("#mtxo").val());
$("#mtxo").click(function(){
$mtco = $("#mtxo").val();

console.log("mtco:%s %s", $mtco, isCheckbox.checked ? 'Is Checked' : 'Is Unchecked');
//$mtco = isCheckbox.checked ? 1 : 0;
//document.write(mtco);
});
});

$("#addnewmarket").click(function(){
var tmarketid = $("#productmarketlist option:selected").val();
Expand Down Expand Up @@ -364,7 +365,7 @@ function checkBrokenLinks($url) {
}
});*/
var data = 'phpfiles/updateprodvendor.php?prodid='+productid+'&vendorid='+vendorid;
$.get(data, function(data){
$.post(data, function(data){
if(data == "SUCCESS") {
$("#product-dialog").dialog("close");

Expand Down
34 changes: 11 additions & 23 deletions admin/phpfiles/saveproductschanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,20 @@
$review_date = isset($_REQUEST['review_date'])?$_REQUEST['review_date']:'';
$www = isset($_REQUEST['www'])?$_REQUEST['www']:'';
$notes = isset($_REQUEST['notes'])?$_REQUEST['notes']:'';
//$mtco = isset($_REQUEST['mtco'])?$_REQUEST['mtco']:'';
$mtco = (isset($_REQUEST['mtco']) && $_REQUEST['mtco']!="")?$_REQUEST['mtco']:0;
//$mtco = '0';
//$mtco = isset($_REQUEST['mtxo'])?$_REQUEST['mtxo']:'';
//$mtco=filter_input(INPUT_POST, 'mtxo', FILTER_SANITIZE_STRING)?"1":"0";
// sanitize the value
//$mtco = filter_input(INPUT_POST, 'mtco', FILTER_SANITIZE_STRING);
/*if(filter_has_var(INPUT_POST,'mtxo')) {
//$mtco='1';
$mtco=$_POST['mtxo']);
<script>
console.log("CHECKBOX:%s %s",filter_input(INPUT_POST, 'mtxo', FILTER_SANITIZE_STRING), $mtco);
</script>
echo "CHECKBOX:".filter_input(INPUT_POST, 'mtxo', FILTER_SANITIZE_STRING);
} else {
$mtco='0';
}*/
/*if (isset($_POST['mtco'])) {
$mtco="1";
} else $mtco = "0";*/
//$mtco = (isset($_REQUEST['mtxo']) && $_REQUEST['mtxo']!="")?1:0;
//$mtco = (empty($_POST['mtco'])) ? 1 : 0;

// fix up review date format
$review_date = (""==$review_date)?'NULL':"'".date('Y-m-d', strtotime($review_date))."'";

/*

todo: change new product function to call edit product with empty id
check for dup product name? product + vendor should be unique yes?

*/

function consoleLog($msg) {
echo '<script type="text/javascript">' . 'console.log(' . $msg . ');</script>';
}

if (empty($id)) {
// add new product & capture ID with SELECT LAST_INSERT_ID();
$sql = "insert product (vendor_id, product_name, status, review_date, www, notes, mtco)
Expand All @@ -62,6 +43,13 @@
www = '".$www."',
notes = '".$notes."',
mtco = ".$mtco." where product_id=".$id;

//$prod = fopen("/tmp/prod.txt", "w");
// writing content to a file using fwrite() function
//echo fwrite($prod, $sql);
// closing the file
//fclose($prod);

mysqli_query($con, $sql) or die(mysqli_error($con));
}

Expand Down