Example #1
0
 function myIncomeOf6Months($supcode)
 {
     //to get total supply for perticular supplier in LAST 6 months
     $dbmain = new DBmain();
     $formateddate = date("Y-m-d");
     $resarr = array();
     $curyear = substr($formateddate, 0, 4);
     $curmonth = substr($formateddate, 5, 7);
     $lstrunningmonth = substr($formateddate, 5, 7);
     for ($i = 1; $i < 7; $i++) {
         $lstrunningmonth = $curmonth - $i;
         $m = $curmonth - $i;
         if ($lstrunningmonth == "0") {
             $curyear = $curyear - 1;
             $m = 12 + ($curmonth - $i);
         }
         if ($lstrunningmonth < 0) {
             $m = 12 + ($curmonth - $i);
         }
         if (strlen($m) == 1) {
             $m = "0" . $m;
         }
         $startday = $curyear . "-" . $m . "-01";
         $enddate = $curyear . "-" . $m . "-31";
         $condition = " WHERE supplier_code='" . $supcode . "' AND date BETWEEN '" . $startday . "' AND '" . $enddate . "'";
         $res = $dbmain->selectData("daily_supply", array("approved_kgs"), $condition);
         $total = 0;
         if (count($res) > 0) {
             foreach ($res as $r) {
                 $total = $total + $r['approved_kgs'];
             }
             $resarr[$i - 1] = $total * DBsms::teaRateofMonth($startday);
         } else {
             $resarr[$i - 1] = 0;
         }
     }
     return $resarr;
 }
Example #2
0
<?php

session_start();
include_once 'message/communication.php';
require_once 'classes/class.user.php';
$user_home = new USER();
require_once 'DB/dbsms.php';
$dbsms = new DBsms();
if (!$user_home->is_logged_in()) {
    $user_home->redirect('index.php');
}
$stmt = $user_home->runQuery("SELECT * FROM users WHERE id=:uid");
$stmt->execute(array(":uid" => $_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$supcode = "";
$supname = "";
$reqtype = "";
$amount = "";
$qty = "";
$category = "";
if (!empty($_GET["id"])) {
    $id = $_GET["id"];
    ?>
  <script type="text/javascript" src="plugins/alert/dist/jquery-1.11.3.min.js"></script>
  <script type="text/javascript" src="plugins/alert/dist/sweetalert.min.js"></script>
  <script type="text/javascript" src="plugins/alert/dist/sweetalert-dev.js"></script>
  <?php 
    $getdata = $user_home->runQuery("SELECT t.supplier_code, s.f_name,s.l_name,t.message_code, t.value, t.quantity, t.category\n  FROM message_temp t,suppliers s,message_info i WHERE (t.supplier_code= s.supplier_code) AND message_id={$id} ");
    $getdata->execute();
    $data = "";
    while ($r = $getdata->FETCH(PDO::FETCH_ASSOC)) {