File manager - Edit - /home/autoph/public_html/pms_v1/dashboard/salesByCompany.php
Back
<?php include_once("../../../cfg/conn.php"); include ("../functions/users.php"); //error_reporting(0); if(isset($_POST['dasales'])){ $dateFrom = sanitize($_POST['dateFrom']); $dateTo = sanitize($_POST['dateTo']); $compNameID = sanitize($_POST['compNameID']); $dealerID = sanitize($_POST['dealerID']); } //echo $dateFrom . " - ".$dateTo; ?> <script> var chart = new CanvasJS.Chart("chartContainerA", { animationEnabled: true, theme: "light2", title:{ text: "Target vs Actual - Company" }, axisX:{ valueFormatString: "DD MMM", crosshair: { enabled: true, snapToDataPoint: true } }, axisY: { title: "No. of Units", includeZero: true, crosshair: { enabled: true } }, toolTip:{ shared:true }, legend:{ cursor:"pointer", verticalAlign: "bottom", horizontalAlign: "left", dockInsidePlotArea: true, itemclick: toogleDataSeries }, data: [{ type: "column", showInLegend: true, name: "Target", markerType: "square", //xValueFormatString: "DD MMM, YYYY", color: "#F08080", indexLabel: "{y}", dataPoints: [ <?php $bName = ''; $count=0; $comID = 0; $getCom = "SELECT * FROM `vts_company` WHERE comp_status =1 AND `brand`='Yes' ORDER BY `comp_code` ASC"; $qCom = mysqli_query($conn,$getCom); while($row = mysqli_fetch_array($qCom)){ $count = $count + 1; $bName = $row['comp_code']; $comID = $row['comp_id']; $opsTar=0; $chkData = "SELECT SUM(`ops_total_target`) AS 'OpsplanTarget' FROM `mancom_data` WHERE `comp_id`='$comID' AND `deleted`=0 AND `date_added` BETWEEN '$dateFrom' AND '$dateTo'"; $qDat = mysqli_query($conn,$chkData); while($rows = mysqli_fetch_array($qDat)){ $opsTar = $rows['OpsplanTarget']; } if($opsTar > 0){ echo "{ label: '".$bName."', y: ".$opsTar." },"; }else{ echo "{ label: '".$bName."', y: 0 },"; } } ?> ] }, { type: "column", showInLegend: true, name: "Actual", lineDashType: "dash", indexLabel: "{y}", dataPoints: [ <?php $bName = ''; $count=0; $comID = 0; $getCom = "SELECT * FROM `vts_company` WHERE comp_status =1 AND `brand`='Yes' ORDER BY `comp_code` ASC"; $qCom = mysqli_query($conn,$getCom); while($row = mysqli_fetch_array($qCom)){ $count = $count + 1; $bName = $row['comp_code']; $comID = $row['comp_id']; $opsSales=0; $chkData = "SELECT SUM(`ops_total_sales`) AS 'opsTotalSales' FROM `mancom_data` WHERE `comp_id`='$comID' AND `deleted`=0 AND `date_added` BETWEEN '$dateFrom' AND '$dateTo'"; $qDat = mysqli_query($conn,$chkData); while($rows = mysqli_fetch_array($qDat)){ $opsSales = $rows['opsTotalSales']; } if($opsSales > 0){ echo "{ label: '".$bName."', y: ".$opsSales." },"; }else{ echo "{ label: '".$bName."', y: 0 },"; } } ?> ] }] }); chart.render(); //========================================================================================== var chart = new CanvasJS.Chart("chartContainerB", { animationEnabled: true, theme: "light2", title: { text: "Sales Progress Report" }, axisX: { title: "Monthly Sales Growth" }, axisY: { title: "Growth Rate", suffix: "%", includeZero: true }, data: [{ type: "line", name: "Sales Progress Report", connectNullData: true, //nullDataLineDashType: "solid", xValueType: "dateTime", xValueFormatString: "YYYY MM", yValueFormatString: "#0.0#", indexLabel: "{y} %", dataPoints: [ <?php $prevMonRate =0; $curMonRate = 0; $opsSales=0; $prevMon=''; $mon = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); foreach($mon as $newMon){ $diffRate = 0; if($prevMon !=''){ $prevSales ="SELECT SUM(`ops_target_vs_actual`) AS PrevMonthlySalesRate FROM `mancom_data` WHERE `month_id`='$prevMon' AND `deleted`=0 AND `date_added` BETWEEN '$dateFrom' AND '$dateTo'"; $qPrevSales = mysqli_query($conn,$prevSales); while($row = mysqli_fetch_array($qPrevSales)){ $prevMonRate = $row['PrevMonthlySalesRate']; } $cusSales ="SELECT SUM(`ops_target_vs_actual`) AS MonthlySalesRate FROM `mancom_data` WHERE `month_id`='$newMon' AND `deleted`=0 AND `date_added` BETWEEN '$dateFrom' AND '$dateTo'"; $qcusSales = mysqli_query($conn,$cusSales); while($crw = mysqli_fetch_array($qcusSales)){ $curMonRate = $crw['MonthlySalesRate']; } //6.25 $diffRate = number_format(($prevMonRate - $curMonRate),2,'.',''); }else{ $cusSales ="SELECT SUM(`ops_target_vs_actual`) AS MonthlySalesRate FROM `mancom_data` WHERE `month_id`='$newMon' AND `deleted`=0 AND `date_added` BETWEEN '$dateFrom' AND '$dateTo'"; $qcusSales = mysqli_query($conn,$cusSales); while($crw = mysqli_fetch_array($qcusSales)){ $curMonRate = $crw['MonthlySalesRate']; } $diffRate = "0"; } echo "{ label: '".$newMon."', y: ".$diffRate." },"; $prevMon = $newMon; $diffRate = 0; } ?> ] }] }); chart.render(); //========================================================================================== function toogleDataSeries(e){ if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) { e.dataSeries.visible = false; } else{ e.dataSeries.visible = true; } chart.render(); } </script> <div id="chartContainerA" style="height: 370px; width: 100%; margin-top:100px"></div> <div id="chartContainerB" style="height: 370px; width: 100%; margin-top:100px"></div> <script src="https://cdn.canvasjs.com/canvasjs.min.js"></script> <?php $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings