Jump to content

Senthilkumar

Members
  • Posts

    184
  • Joined

  • Last visited

Community Answers

  1. Senthilkumar's post in Displaying the dynamically added data to existing table was marked as the answer   
    Dear Mr. Mac_gyver,
    thanks for your reply. I changed the code as per your suggestion. Count the number of rows in the table body. Now it is working properly
    <script> $(document).ready(function () { const tbody = document.querySelector('#product_data tbody'); // Get all the tr elements within the tbody const rows = tbody.getElementsByTagName('tr'); // Get the count of tr elements const rowCount = rows.length; $("#addRow").click(function () { const tbody = document.querySelector('#product_data tbody'); // Get all the tr elements within the tbody const rows = tbody.getElementsByTagName('tr'); // Get the count of tr elements const rowCount = rows.length; var n = rowCount + 1; // Counter for rows var newRow = `<tr> <td align='center'>${n}</td> <td><input type="text" name="CustomerName[]" class="form-control" /></td> <td><input type="text" name="CustomerCity[]" class="form-control" /></td> <td> <select name="interval[]" class="form-control form-select"> <option value="">Choose</option> <option value="Monthly">Monthly</option> <option value="Quarterly">Quarterly</option> </select> </td> <td> <select name="plan[]" class="form-control form-select"> <option value="">Select Interval</option> <option value="1st Week">1st Week</option> <option value="2nd Week">2nd Week</option> <option value="3rd Week">3rd Week</option> <option value="4th Week">4th Week</option> <option value="1st Month">1st Month</option> <option value="2nd Month">2nd Month</option> <option value="3rd Month">3rd Month</option> </select> </td> <td> <select name="type[]" class="form-control form-select" onchange="toggleDateField('new_${n}')"> <option value="">Choose</option> <option value="Direct">Direct</option> <option value="Telephone">Telephone</option> <option value="Not Visited">Not Visited</option> <option value="No Due">No Due</option> </select> </td> <td align='center'> <input type="date" name="SubmitedDate[]" class="form-control border border-success SubmitedDate" autocomplete="off" /> </td> <td align='center'> <input type="text" name="Remarks[]" class="form-control border border-success Remarks" autocomplete="off" /> </td> <td> <input type="text" name="lang[]" value="new_${n++}" class="form-control border border-success" autocomplete="off" /> </td> </tr>`; $("#product_data tbody").append(newRow); }); }); } </script> Please give your feedback
  2. Senthilkumar's post in Pass the PHP vaiable to js file using ajax script was marked as the answer   
    I changed the code as per your instructions. Now it is working.
    <?PHP include("../connection.php"); $Month = $_POST["Month"]; $Region = $_POST["Region"]; $Equipment = $_POST["Equipment"]; if ($Equipment == '') { $EquipCondition = ''; } else { $EquipCondition = 'AND ModelGroup = ' .$Equipment.''; } if ($Region == '') { $Mc = "SELECT Region, CuTotal, CuAssigned FROM ( SELECT count(distinct a.CustomerID) as CuTotal, c.regnName as Region FROM sbms.machinemaster as a inner join sbms.branch as b on b.branchcode = a.BranchCode inner join sbms.region as c on c.regnID = b.regnID WHERE a.MachineStatus = 'A' $EquipCondition AND c.regnID !='5' group by c.regnID) total LEFT JOIN (Select count(a.RowID) as CuAssigned , c.regnName as Region FROM sbms.customerdata as a inner join sbms.branch as b on b.branchID = a.Branch inner join sbms.region as c on c.regnID = b.regnID inner join sbms.machinemaster as d on d.id = a.RowID WHERE a.Month = '$Month' $EquipCondition and d.MachineStatus='A' AND a.VisitType !='No Due' AND a.Status ='1' group by c.regnID order by c.regnID ASC ) assigned USING (Region)"; $Mcresult = mysqli_query($conn, $Mc); $McNoRow = mysqli_num_rows($Mcresult); $return_arr[] = array('Region', 'Active Customer', 'Visited'); while ($Mcrow = mysqli_fetch_array($Mcresult)) { $CustRegion = $Mcrow['Region']; $CusTotal = $Mcrow['CuTotal']; $CusAssigned = $Mcrow['CuAssigned']; $return_arr1[] = array( $CustRegion ); $return_arr2[] = array( $CusTotal ); $return_arr3[] = array( $CusAssigned ); } echo json_encode(array("CustRegion" => $return_arr1, "CusTotal" => $return_arr2, "CusAssigned" => $return_arr3)); } if ($Region !== '') { $Mc = "SELECT Branch, McTotal, McAssigned FROM ( SELECT count(distinct a.CustomerID) as McTotal, b.branchName as Branch FROM sbms.machinemaster as a inner join sbms.branch as b on b.branchcode = a.BranchCode inner join sbms.region as c on c.regnID = b.regnID WHERE a.MachineStatus = 'A' $EquipCondition AND c.regnID ='$Region' group by b.branchcode) total LEFT JOIN (Select count(a.RowID) as McAssigned , b.branchName as Branch FROM sbms.customerdata as a inner join sbms.branch as b on b.branchID = a.Branch inner join sbms.region as c on c.regnID = b.regnID inner join sbms.machinemaster as d on d.id = a.RowID WHERE a.Month = '$Month' $EquipCondition and d.MachineStatus='A' AND b.regnID = '$Region' AND a.VisitType !='No Due' AND a.Status ='1' group by b.branchID ) assigned USING (Branch)"; $Mcresult = mysqli_query($conn, $Mc); $McNoRow = mysqli_num_rows($Mcresult); $return_arr[] = array('Region', 'Active Machine', 'Procuction Data Collected'); while ($Mcrow = mysqli_fetch_array($Mcresult)) { $CustRegion = $Mcrow['Branch']; $CusTotal = $Mcrow['McTotal']; $CusAssigned = $Mcrow['McAssigned']; $return_arr1[] = array( $CustRegion ); $return_arr2[] = array( $CusTotal ); $return_arr3[] = array( $CusAssigned ); } echo json_encode(array("CustRegion" => $return_arr1, "CusTotal" => $return_arr2, "CusAssigned" => $return_arr3)); } ?> <script type="text/javascript"> $(document).ready(function () { ProductionFilter(); }); $(document).on('change', '.filter', function () { ProductionFilter(); }); function ProductionFilter() { var Month = document.getElementById("Month").value; var Region = document.getElementById("Region").value; var Branch = document.getElementById("Branch").value; var Equipment = document.getElementById("Equipment").value; $.ajax({ url: 'Customer_Graph_Filter.php', type: 'POST', data: 'Month=' + Month + '&Region=' + Region + '&Branch=' + Branch + '&Equipment=' + Equipment, dataType: 'JSON', success: function (response) { var CustomerRegion = response.CustRegion; var CustomerAssigned = response.CusAssigned; var CustomerTotal = response.CusTotal; var barChartData = { labels: CustomerRegion, datasets: [{ label: 'Total Customers', backgroundColor: 'rgba(0, 158, 251, 0.5)', borderColor: 'rgba(0, 158, 251, 1)', borderWidth: 1, data: CustomerTotal }, { label: 'Data Collected', backgroundColor: 'rgba(255, 188, 53, 0.5)', borderColor: 'rgba(255, 188, 53, 1)', borderWidth: 1, data: CustomerAssigned }] }; var myoption = { responsive: true, tooltips: { enabled: true }, hover: { animationDuration: 1 }, scales: { yAxes: [{ ticks: { beginAtZero: true, } }], xAxes: [{ ticks: { autoSkip: false } }] }, animation: { duration: 1, onComplete: function () { var chartInstance = this.chart, ctx = chartInstance.ctx; ctx.textAlign = 'center'; ctx.fillStyle = "rgba(0, 0, 0, 1)"; ctx.textBaseline = 'bottom'; this.data.datasets.forEach(function (dataset, i) { var meta = chartInstance.controller.getDatasetMeta(i); meta.data.forEach(function (bar, index) { var data = dataset.data[index]; ctx.fillText(data, bar._model.x, bar._model.y + 1); }); }); } }, maintainAspectRatio: true }; var ctx = document.getElementById('CustomerBarGraph').getContext('2d'); window.myBar = new Chart(ctx, { type: 'bar', data: barChartData, options: myoption, }); } }); } </script> Thanks for your support
  3. Senthilkumar's post in Problem on sum of column in INNER JOIN query was marked as the answer   
    Dear Barand,
    Thanks for your support. It is working now.
  4. Senthilkumar's post in Fetch the data from databse and display in table based on the month selection was marked as the answer   
    Dear Barand,
     
    Thanks for your reply. It is the problem of space on the the ID name. Now i removed the space on Category and Description using the bellow code
    $Description = str_replace(' ', '', $row['Description']); Now all the target values are updating properly

     
    Once again thank you team for supporting me to complete this.
  5. Senthilkumar's post in Real time Java script calculation for update Row & column total was marked as the answer   
    Dear mac_gyver,
    Thanks for your suggession. I had changed the input name for the row total. So now it is updating properly as per my requirement.
     
    Thaks for your support.
  6. Senthilkumar's post in Retrive data from database and display in table based on month selection was marked as the answer   
    Dear Mac-Gayer,
    Thanks for your reply.
     
    I created span
    <span id=file1<?php echo $row['Ass_ID']; ?>><a></a></span> And i append my Directory & Document on this span.
    $("#file1" + Ass_ID).append('<a target="_blank" href="' + Directory + '/' + Document + '">' + Document + '</a>'); Now it is working properly.

     
    Thank you for supporting me.
  7. Senthilkumar's post in Filter the data table based on the User Login was marked as the answer   
    Dear Mr.Barand,
    I got the solution what i want exactly. Thanks for your immediate support.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.