Ejemplo n.º 1
0
 function getTodayTotalSupply()
 {
     $dbmain = new DBmain();
     $res = $dbmain->selectData("today_supply", array("approved_kgs"), " ");
     $total = 0;
     if (count($res) > 0) {
         foreach ($res as $r) {
             $total = $total + $r['approved_kgs'];
         }
         return $total;
     }
 }
Ejemplo n.º 2
0
 function getBasicSupData($supcode)
 {
     $dbmain = new DBmain();
     $condition = "WHERE supplier_code='" . $supcode . "'";
     $res = $dbmain->selectData("suppliers", array("f_name", "l_name", "address_1", "address_2", "address_3", "nic_no"), $condition);
     if (count($res) == 1) {
         foreach ($res as $r) {
             //print_r($r);
             return $r;
         }
     }
 }
Ejemplo n.º 3
0
 function factoryTotalSupplyOf12Months()
 {
     $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 < 13; $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 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;
         } else {
             $resarr[$i - 1] = 0;
         }
     }
     return $resarr;
 }
Ejemplo n.º 4
0
 function approxTeaRatesOfLast6Months()
 {
     $dbmain = new DBmain();
     $formateddate = date("Y-m-d");
     $resarr = array();
     $curyear = substr($formateddate, 0, 4);
     $curmonth = substr($formateddate, 5, 7);
     $curmonth = $curmonth * 1 + 1;
     $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 date BETWEEN '" . $startday . "' AND '" . $enddate . "'";
         $res = $dbmain->selectData("settings", array("approxi_tea_rate"), $condition);
         $total = 0;
         if (count($res) > 0) {
             foreach ($res as $r) {
                 $total = $total + $r['approxi_tea_rate'];
             }
             $resarr[$i - 1] = $total;
         } else {
             $resarr[$i - 1] = 0;
         }
     }
     return $resarr;
 }
Ejemplo n.º 5
0
 function teaRateofMonth($formateddate)
 {
     $dbmain = new DBmain();
     $startday = substr($formateddate, 0, 7) . "-01";
     $enddate = substr($formateddate, 0, 7) . "-31";
     $condition = " WHERE date BETWEEN '" . $startday . "' AND '" . $enddate . "'";
     $res = $dbmain->selectData("settings", array("approxi_tea_rate", "fixed_tea_rate"), $condition);
     if (count($res) == 1) {
         foreach ($res as $r) {
             $approx = $r['approxi_tea_rate'];
             $real = $r['fixed_tea_rate'];
             if ($real != NULL || $real != 0) {
                 return $real;
             } else {
                 return $approx;
             }
         }
     } elseif (count($res) > 1) {
         $approx = "";
         $real = "";
         foreach ($res as $r) {
             $approx = $r['approxi_tea_rate'];
             $real = $r['fixed_tea_rate'];
         }
         return $real;
     } else {
         return 0;
     }
 }