Ejemplo n.º 1
0
 public static function modifyCostCenter($projectId, $segmentData, $costCentermaterials, $userId)
 {
     $db = Database::getInstance();
     $conn = $db->getConnection();
     $conn->beginTransaction();
     try {
         $stmt1 = $conn->prepare("DELETE FROM `budget_details` where projectid=:projectid");
         $stmt1->bindParam(':projectid', $projectId);
         if ($stmt1->execute()) {
             $stmt2 = $conn->prepare("DELETE FROM `material_budget_details` where projectid=:projectid");
             $stmt2->bindParam(':projectid', $projectId);
             if ($stmt2->execute()) {
                 $success = false;
                 HicreteLogger::logInfo("Creating cost center");
                 foreach ($segmentData as $segment) {
                     $budgetId = AppUtil::generateId();
                     $stmt = $conn->prepare("INSERT INTO `budget_details`(`budgetdetailsid`,`projectid`, `budgetsegmentid`, `allocatedbudget`, `alertlevel`, `createdby`, `creationdate`, `lastmodificationdate`, `lastmodifiedby`)\n                    VALUES (:budgetId,:projectId,:segmentId,:allocatedBudget,:alertLevel,:createdBy,now(),now(),:lastModifiedBy)");
                     $stmt->bindParam(':budgetId', $budgetId, PDO::PARAM_STR);
                     $stmt->bindParam(':projectId', $projectId, PDO::PARAM_STR);
                     $stmt->bindParam(':segmentId', $segment->budgetsegmentid, PDO::PARAM_STR);
                     $stmt->bindParam(':allocatedBudget', $segment->allocatedbudget, PDO::PARAM_INT);
                     $stmt->bindParam(':alertLevel', $segment->alertlevel, PDO::PARAM_STR);
                     $stmt->bindParam(':createdBy', $userId, PDO::PARAM_STR);
                     $stmt->bindParam(':lastModifiedBy', $userId, PDO::PARAM_STR);
                     HicreteLogger::logDebug("Query: \n" . json_encode($stmt));
                     if ($stmt->execute()) {
                         $success = true;
                     } else {
                         $success = false;
                     }
                 }
                 if ($costCentermaterials != null) {
                     foreach ($costCentermaterials as $material) {
                         $materialbudgetdetailsid = uniqid();
                         $stmtCostCenterMaterial = $conn->prepare("INSERT INTO `material_budget_details`(`materialbudgetdetailsid`,`projectid`,`materialid` ,`allocatedbudget`, `alertlevel`, `creadtedby`, `creationdate`, `lastmodificationdate`, `lastmodifiedby`)\n                    VALUES (:materialbudgetdetailsid,:projectId,:materialid,:allocatedBudget,:alertLevel,:creadtedby,now(),now(),:lastmodifiedby)");
                         $stmtCostCenterMaterial->bindParam(':materialbudgetdetailsid', $materialbudgetdetailsid, PDO::PARAM_STR);
                         $stmtCostCenterMaterial->bindParam(':projectId', $projectId, PDO::PARAM_STR);
                         $stmtCostCenterMaterial->bindParam(':materialid', $material->materialid, PDO::PARAM_STR);
                         $stmtCostCenterMaterial->bindParam(':allocatedBudget', $material->allocatedbudget, PDO::PARAM_INT);
                         $stmtCostCenterMaterial->bindParam(':alertLevel', $material->alertlevel, PDO::PARAM_STR);
                         $stmtCostCenterMaterial->bindParam(':creadtedby', $userId, PDO::PARAM_STR);
                         $stmtCostCenterMaterial->bindParam(':lastmodifiedby', $userId, PDO::PARAM_STR);
                         if ($stmtCostCenterMaterial->execute()) {
                             $success = true;
                         } else {
                             $success = false;
                         }
                     }
                 }
                 if ($success) {
                     $conn->commit();
                     $message = "Cost Center Updated successfully..!!!";
                     HicreteLogger::logInfo("Cost center Updated  successfully");
                     echo AppUtil::getReturnStatus("success", $message);
                 } else {
                     $conn->rollBack();
                     $message = "Could not create cost center..!!!";
                     HicreteLogger::logError("Error while creating cost center");
                     echo AppUtil::getReturnStatus("failure", $message);
                 }
             }
         } else {
             $conn->rollBack();
             $message = "Could not update cost center..!!!";
             HicreteLogger::logError("Error while updating cost center");
             echo AppUtil::getReturnStatus("failure", $message);
         }
     } catch (Exception $e) {
         $conn->rollBack();
         HicreteLogger::logError("Exception while updating cost center");
         echo AppUtil::getReturnStatus("failure", $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 public static function CancelTempAccessRequest($requestId)
 {
     try {
         $db = Database::getInstance();
         $conn = $db->getConnection();
         HicreteLogger::logInfo("Adding temporary request");
         $stmt = $conn->prepare("UPDATE `tempaccessrequest` SET `status`='Cancel' WHERE `requestId`=:requestId");
         $stmt->bindParam(':requestId', $requestId, PDO::PARAM_STR);
         HicreteLogger::logDebug("Query:\n " . json_encode($stmt));
         if ($stmt->execute()) {
             HicreteLogger::logInfo("Access request added");
             echo AppUtil::getReturnStatus("Successful", "Access Request Added");
         } else {
             HicreteLogger::logError("Unknown databse error occured");
             echo AppUtil::getReturnStatus("Unsuccessful", "Unknown database error occurred");
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception Occured Message:\n" . $e->getMessage());
         echo AppUtil::getReturnStatus("Exception", $e->getMessage());
     }
 }
Ejemplo n.º 3
0
 public function addSupplierToDb($dbh, $userId, $supplier)
 {
     $delFlgDflt = 'N';
     try {
         $stmt = $dbh->prepare("INSERT INTO supplier (SUPPLIERNAME,CONTACTNO,POINTOFCONTACT,OFFICENO,CSTNO,VATNO,ADDRESS,CITY,COUNTRY,PINCODE,DELFLG,LCHNGUSERID,LCHNGTIME,CREUSERID,CRETIME)\n              values (:supplierName,:contactNo,:pointofcontact,:officeno,:cstno,:vatno,:address,:city,:country,:pincode,:delflg,:lchngUserId,now(),:creUserId,now())");
         $stmt->bindParam(':supplierName', $supplier->supplierName);
         $stmt->bindParam(':contactNo', $supplier->contactNo);
         $stmt->bindParam(':pointofcontact', $supplier->pointOfContact);
         $stmt->bindParam(':officeno', $supplier->officeNo);
         $stmt->bindParam(':cstno', $supplier->CSTNo);
         $stmt->bindParam(':vatno', $supplier->VATNo);
         $stmt->bindParam(':address', $supplier->address);
         $stmt->bindParam(':city', $supplier->city);
         $stmt->bindParam(':country', $supplier->country);
         $stmt->bindParam(':pincode', $supplier->pinCode);
         $stmt->bindParam(':delflg', $delFlgDflt);
         $stmt->bindParam(':lchngUserId', $userId);
         $stmt->bindParam(':creUserId', $userId);
         HicreteLogger::logDebug("Query:\n " . json_encode($stmt));
         HicreteLogger::logDebug("Data:\n " . json_encode($supplier));
         if ($stmt->execute()) {
             HicreteLogger::logInfo("Supplier Created successfully");
             $message = "Supplier Created successfully";
             $arr = array('msg' => $message, 'error' => '');
             $jsn = json_encode($arr);
             echo $jsn;
             //   return $message;
         } else {
             HicreteLogger::logInfo("Supplier Creation failed");
             $message = "Issues while adding supplier.Please contact administrator ";
             $arr = array('msg' => $message, 'error' => '');
             $jsn = json_encode($arr);
             echo $jsn;
             // return $message;
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception Occured Message:\n" . $e->getMessage());
         $message = "Exception thrown";
         return $message;
     }
 }
Ejemplo n.º 4
0
$dbh = $db->getConnection();
$mData = json_decode($_GET["data"]);
if (isset($mData->keyword)) {
    $keyword = "%" . $mData->keyword . "%";
}
$selectStatement = "SELECT product_master.productmasterid,product_master.`productname`,product_master.`unitofmeasure`,product_details.`color`,product_details.`description`, product_details.`alertquantity`,product_packaging.`packaging`,material.`materialid`,material.`abbrevation`,materialtype.`materialtypeid`,materialtype.`materialtype` FROM product_master JOIN product_details ON product_master.productmasterid=product_details.productmasterid JOIN product_packaging ON product_master.productmasterid=product_packaging.productmasterid JOIN material ON product_master.productmasterid=material.productmasterid JOIN materialtype ON materialtype.materialtypeid=product_master.materialtypeid ";
if (isset($mData->SearchTerm)) {
    switch ($mData->SearchTerm) {
        case 'productName':
            $selectStatement = $selectStatement . " WHERE product_master.productname like :keyword ORDER BY product_master.`productname`,product_details.`color`,product_master.`unitofmeasure` DESC";
            break;
        case 'materialType':
            $selectStatement = $selectStatement . " WHERE materialtype.materialtype like :keyword ORDER BY product_master.`productname`,product_details.`color`,product_master.`unitofmeasure` DESC";
            break;
    }
}
//echo $selectStatement;
$stmt = $dbh->prepare($selectStatement);
HicreteLogger::logInfo("Searching Products");
HicreteLogger::logDebug("Query: " . json_encode($stmt));
HicreteLogger::logDebug("Data: " . json_encode($mData));
if (isset($mData->SearchTerm)) {
    if ($mData->SearchTerm == 'productName' || $mData->SearchTerm == 'materialType') {
        $stmt->bindParam(':keyword', $keyword, PDO::PARAM_STR, 10);
    }
}
$stmt->execute();
//$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$result = $stmt->fetchAll();
$json = json_encode($result);
echo $json;
Ejemplo n.º 5
0
 public function insertOutwardInToDb($dbh, $userId, $data)
 {
     try {
         //BEGIN THE TRANSACTION
         $dbh->beginTransaction();
         HicreteLogger::logInfo("Inserting outward entries");
         $date = new DateTime($this->dateOfOutward);
         $dob = $date->format('Y-m-d');
         $stmtOutward = $dbh->prepare("INSERT INTO outward (warehouseid,companyid,supervisorid,dateofentry,outwardno,lchnguserid,lchngtime,creuserid,cretime)\n                           values (:warehouseid,:companyid,:supervisorid,:dateofentry,:Outwardno,:lchnguserid,now(),:creuserid,now())");
         $stmtOutward->bindParam(':warehouseid', $this->warehouse, PDO::PARAM_STR, 10);
         $stmtOutward->bindParam(':companyid', $this->companyName, PDO::PARAM_STR, 10);
         $stmtOutward->bindParam(':supervisorid', $this->suppervisor, PDO::PARAM_STR, 10);
         $stmtOutward->bindParam(':dateofentry', $dob, PDO::PARAM_STR, 40);
         $stmtOutward->bindParam(':Outwardno', $this->OutwardNumber, PDO::PARAM_STR, 10);
         $stmtOutward->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
         $stmtOutward->bindParam(':creuserid', $userId, PDO::PARAM_STR, 10);
         HicreteLogger::logDebug("Query: " . json_encode($stmtOutward));
         HicreteLogger::logDebug("Data: " . json_encode($this));
         if ($stmtOutward->execute()) {
             HicreteLogger::logInfo("Insertion to outward successful. Inserting outward details");
             $lastOutwardId = $dbh->lastInsertId();
             $materials = $data->outwardData->outwardMaterials;
             //Insert Data into Outward Details table
             foreach ($materials as $material) {
                 $stmtOutwardDetails = $dbh->prepare("INSERT INTO outward_details (Outwardid,materialid,quantity,packagedunits,packagesize,lchnguserid,lchngtime,creuserid,cretime)\n              values (:Outwardid,:materialid,:quantity,:packagedunits,:packagesize,:lchnguserid,now(),:creuserid,now())");
                 $stmtOutwardDetails->bindParam(':Outwardid', $lastOutwardId, PDO::PARAM_STR, 10);
                 $stmtOutwardDetails->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                 $stmtOutwardDetails->bindParam(':quantity', $material->materialQuantity, PDO::PARAM_STR, 40);
                 $stmtOutwardDetails->bindParam(':packagedunits', $material->packageUnit, PDO::PARAM_STR, 10);
                 $stmtOutwardDetails->bindParam(':packagesize', $material->packagesize, PDO::PARAM_STR, 10);
                 $stmtOutwardDetails->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
                 $stmtOutwardDetails->bindParam(':creuserid', $userId, PDO::PARAM_STR, 10);
                 HicreteLogger::logDebug("Query: " . json_encode($stmtOutwardDetails));
                 HicreteLogger::logDebug("Data: " . json_encode($material));
                 if ($stmtOutwardDetails->execute()) {
                     $isSuccess = true;
                     // I CAN OPTIMIZE THIS CODE
                     HicreteLogger::logInfo(" Inserting outward details successfull updating inventory");
                     $result = null;
                     $stmtInventoryCount = $dbh->prepare("SELECT totalquantity from inventory  WHERE materialid = :materialid");
                     $stmtInventoryCount->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                     $stmtInventoryCount->execute();
                     // if($stmtInventoryCount->execute()){
                     $result = $stmtInventoryCount->setFetchMode(PDO::FETCH_ASSOC);
                     $result = $stmtInventoryCount->fetch(PDO::FETCH_ASSOC);
                     // }
                     if ($result['totalquantity'] != 0) {
                         HicreteLogger::logInfo("Updating inventory");
                         $stmtInventory = $dbh->prepare("UPDATE inventory SET totalquantity =totalquantity- :totalquantity\n                    WHERE materialid = :materialid");
                         $stmtInventory->bindParam(':totalquantity', $material->materialQuantity, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                         if ($stmtInventory->execute()) {
                             $isSuccess = true;
                         } else {
                             HicreteLogger::logError("Error in updating or inserting main table");
                             $this->showAlert('Failure', "Error 3rd");
                             $isSuccess = false;
                         }
                     } else {
                         HicreteLogger::logError("Error in inserting outward details");
                         $this->showAlert('Failure', "Error 2nd");
                         $isSuccess = false;
                     }
                 } else {
                     HicreteLogger::logError("Error in inserting outward details");
                     $this->showAlert('Failure', "Error 1st");
                     $isSuccess = false;
                 }
             }
             if ($isSuccess) {
                 $lastOutwardDetailsId = $dbh->lastInsertId();
                 // Insert Data into Transport Details Table
                 if ($this->hasTransportDetails == 'Yes') {
                     HicreteLogger::logInfo("Inserting transport details ");
                     $stmtTransportDetails = $dbh->prepare("INSERT INTO outward_transportation_details (Outwardid,transportationmode,vehicleno,drivername,transportagency,cost,lchnguserid,lchngtime,creuserid,cretime,remark)\n               values (:Outwardid,:transportationmode,:vehicleno,:drivername,:transportagency,:cost,:lchnguserid,now(),:creuserid,now(),:remark)");
                     $stmtTransportDetails->bindParam(':Outwardid', $lastOutwardId, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':transportationmode', $this->transportMode, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':vehicleno', $this->vehicleNumber, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':drivername', $this->driverName, PDO::PARAM_STR, 40);
                     $stmtTransportDetails->bindParam(':transportagency', $this->transportAgency, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':cost', $this->transportCost, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':creuserid', $userId, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':remark', $this->remark, PDO::PARAM_STR, 10);
                     if ($stmtTransportDetails->execute()) {
                         HicreteLogger::logInfo("Outward details added successfully");
                         $this->showAlert('success', "Outward details added Successfully!!!");
                         $dbh->commit();
                     } else {
                         HicreteLogger::logError("Error in inserting outward transport details");
                         $this->showAlert('Failure', "Error while adding 3rd");
                         $dbh->rollBack();
                     }
                 } else {
                     HicreteLogger::logInfo("Outward details added successfully");
                     $this->showAlert('success', "Outward details added Successfully!!!");
                     $dbh->commit();
                 }
             } else {
                 HicreteLogger::logError("Error in inserting outward details");
                 $this->showAlert('Failure', "Error while adding 2nf");
                 $dbh->rollBack();
             }
         } else {
             HicreteLogger::logError("Error in inserting outward");
             $this->showAlert('Failure', "Error while adding 1st");
             $dbh->rollBack();
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception occured \n" . $e->getMessage());
         echo $e->getMessage();
     }
 }
Ejemplo n.º 6
0
 public function updateLeaveApprovalStatus($userId, $data)
 {
     $db = Database::getInstance();
     $connect = $db->getConnection();
     $status = $data->status;
     $applicationId = $data->applicationId;
     try {
         $stmt = $connect->prepare("UPDATE leave_application_master SET\n                                         status=:status,\n                                         action_by=:actionBy,\n                                         action_date=NOW()\n                                         WHERE application_id=:applicationId");
         $stmt->bindParam(':status', $status);
         $stmt->bindParam(':actionBy', $userId);
         $stmt->bindParam(':applicationId', $applicationId);
         $connect->beginTransaction();
         HicreteLogger::logDebug("query: \n" . json_encode($stmt));
         HicreteLogger::logDebug("Data: \n" . json_encode($data));
         if ($stmt->execute()) {
             HicreteLogger::logInfo("Status Updated Successfully");
             echo AppUtil::getReturnStatus("success", "Status Updated Successfully");
             $connect->commit();
             return true;
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception Occured Message:\n" . $e->getMessage());
         echo AppUtil::getReturnStatus("fail", "Exception While Updating Leave Approval");
     }
 }
Ejemplo n.º 7
0
 public function addToInhouseTransport($dbh, $userId)
 {
     try {
         //$dbh->beginTransaction();
         $stmt = $dbh->prepare("INSERT INTO inhouse_transportation_details (inhouseinwardid,transportationmode,vehicleno,drivername,transportagency,cost,LCHNGUSERID,LCHNGTIME,CREUSERID,CRETIME) \n              values (:inhouseinwardid,:transportationmode,:vehicleno,:drivername,:transportagency,:cost,:lchngUserId,now(),:creUserId,now())");
         $stmt->bindParam(':inhouseinwardid', $this->inhouseInwardId, PDO::PARAM_STR, 10);
         $stmt->bindParam(':transportationmode', $this->modeOfTransport, PDO::PARAM_STR, 10);
         $stmt->bindParam(':vehicleno', $this->vehicleNo, PDO::PARAM_STR, 10);
         $stmt->bindParam(':drivername', $this->driver, PDO::PARAM_STR, 10);
         $stmt->bindParam(':transportagency', $this->TranspAgency, PDO::PARAM_STR, 10);
         $stmt->bindParam(':cost', $this->cost, PDO::PARAM_STR, 10);
         $stmt->bindParam(':lchngUserId', $userId, PDO::PARAM_STR, 10);
         $stmt->bindParam(':creUserId', $userId, PDO::PARAM_STR, 10);
         HicreteLogger::logDebug("Query: \n" . json_encode($stmt));
         if ($stmt->execute()) {
             HicreteLogger::logInfo("Insert to inhouse_transport_details successful");
             return 1;
         } else {
             HicreteLogger::logError("Insert to inhouse_transport_details unsuccessful");
             return 0;
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception occured: \n" . $e->getMessage());
     }
 }
                 $count++;
             }
         }
         if ($count == sizeof($data->data)) {
             HicreteLogger::logInfo("Material type Added successfully");
             $arr = array('msg' => "Material type added Successfully!!!", 'error' => '');
             $jsn = json_encode($arr);
             echo $jsn;
         } else {
             HicreteLogger::logError("Material type Not added successfully");
             $arr = array('msg' => '', 'error' => "Material Type not added due to technical reasons Please try after some time ");
             $jsn = json_encode($arr);
             echo $jsn;
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception occured :\n" . $e->getMessage());
         $arr = array('msg' => '', 'error' => "Exception occured Please contact administrator");
         $jsn = json_encode($arr);
         echo $jsn;
     }
     break;
 case 'fetch':
     try {
         $dfltDelFlg = 'Y';
         $stmt = $dbh->prepare("Select materialtypeid,materialtype from materialtype where delflg!=:delflg");
         $stmt->bindParam(':delflg', $dfltDelFlg, PDO::PARAM_STR, 10);
         if ($stmt->execute()) {
             $json_array = array();
             while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
                 $materialTypes['materialtypeid'] = $result['materialtypeid'];
                 $materialTypes['materialtype'] = $result['materialtype'];
Ejemplo n.º 9
0
 public function insertInwardInToDb($dbh, $userId, $data)
 {
     try {
         //Begin Transaction
         $dbh->beginTransaction();
         //Create preapred Statement
         $date = new DateTime($this->dateOfInward);
         $inwardDate = $date->format('Y-m-d');
         HicreteLogger::logInfo("Inserting inward entries");
         $stmtInward = $dbh->prepare("INSERT INTO inward (warehouseid,companyid,supervisorid,dateofentry,inwardno,lchnguserid,lchngtime,creuserid,cretime)\n             values (:warehouseid,:companyid,:supervisorid,:dateofentry,:inwardno,:lchnguserid,now(),:creuserid,now())");
         $stmtInward->bindParam(':warehouseid', $this->warehouse, PDO::PARAM_STR, 10);
         $stmtInward->bindParam(':companyid', $this->companyName, PDO::PARAM_STR, 10);
         $stmtInward->bindParam(':supervisorid', $this->suppervisor, PDO::PARAM_STR, 10);
         $stmtInward->bindParam(':dateofentry', $inwardDate, PDO::PARAM_STR, 40);
         $stmtInward->bindParam(':inwardno', $this->inwardNumber, PDO::PARAM_STR, 10);
         $stmtInward->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
         $stmtInward->bindParam(':creuserid', $userId, PDO::PARAM_STR, 10);
         HicreteLogger::logDebug("Query: \n" . json_encode($stmtInward));
         HicreteLogger::logDebug("DATA: \n" . json_encode($this));
         if ($stmtInward->execute()) {
             HicreteLogger::logInfo("Insertion to Inward successful.Inserting inward Details");
             $lastInwardId = $dbh->lastInsertId();
             $materials = $data->inwardData->inwardMaterials;
             //Insert Data into Inward Details table
             foreach ($materials as $material) {
                 $stmtInwardDetails = $dbh->prepare("INSERT INTO inward_details (inwardid,materialid,supplierid,quantity,packagedunits,size,lchnguserid,lchngtime,creuserid,cretime)\n                    values (:inwardid,:materialid,:supplierid,:quantity,:packagedunits,:size,:lchnguserid,now(),:creuserid,now())");
                 $stmtInwardDetails->bindParam(':inwardid', $lastInwardId, PDO::PARAM_STR, 10);
                 $stmtInwardDetails->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                 $stmtInwardDetails->bindParam(':supplierid', $material->suppplierName, PDO::PARAM_STR, 10);
                 $stmtInwardDetails->bindParam(':quantity', $material->materialQuantity, PDO::PARAM_STR, 40);
                 $stmtInwardDetails->bindParam(':packagedunits', $material->packageUnit, PDO::PARAM_STR, 10);
                 $stmtInwardDetails->bindParam(':size', $material->packagesize, PDO::PARAM_STR, 10);
                 $stmtInwardDetails->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
                 $stmtInwardDetails->bindParam(':creuserid', $userId, PDO::PARAM_STR, 10);
                 HicreteLogger::logDebug("Query: \n" . json_encode($stmtInwardDetails));
                 HicreteLogger::logDebug("DATA: \n" . json_encode($material));
                 if ($stmtInwardDetails->execute()) {
                     $isSuccess = true;
                     HicreteLogger::logInfo("Insertion of Inward Details successful.Updating inventory");
                     //Check if material already exist in inventory table if yes update else Insert
                     $stmtAvailabiltyCheck = $dbh->prepare("SELECT materialid FROM inventory WHERE materialid=:materialid ");
                     $stmtAvailabiltyCheck->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                     $stmtAvailabiltyCheck->execute();
                     $count = $stmtAvailabiltyCheck->rowcount();
                     if ($count != 0) {
                         //UPDATE
                         HicreteLogger::logInfo("Updating inventory");
                         $stmtInventory = $dbh->prepare("UPDATE inventory SET totalquantity =totalquantity+ :totalquantity,\n                                        warehouseid=:warehouseid,companyid=:companyid\n                            WHERE materialid = :materialid");
                         $stmtInventory->bindParam(':totalquantity', $material->materialQuantity, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':warehouseid', $this->warehouse, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':companyid', $this->companyName, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                         HicreteLogger::logDebug("Query: \n" . json_encode($stmtInventory));
                         if ($stmtInventory->execute()) {
                             $isSuccess = true;
                         } else {
                             $isSuccess = false;
                         }
                     } else {
                         //Insert
                         HicreteLogger::logInfo("Inserting to inventory");
                         $stmtInventory = $dbh->prepare("INSERT INTO inventory (materialid,warehouseid,companyid,totalquantity)\n                                                      values (:materialid,:warehouseid,:companyid,:totalquantity)");
                         $stmtInventory->bindParam(':totalquantity', $material->materialQuantity, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':warehouseid', $this->warehouse, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':companyid', $this->companyName, PDO::PARAM_STR, 10);
                         $stmtInventory->bindParam(':materialid', $material->material, PDO::PARAM_STR, 10);
                         HicreteLogger::logDebug("Query: \n" . json_encode($stmtInventory));
                         if ($stmtInventory->execute()) {
                             $isSuccess = true;
                         } else {
                             $isSuccess = false;
                         }
                     }
                 } else {
                     $isSuccess = false;
                 }
             }
             if ($isSuccess) {
                 $lastInwardDetailsId = $dbh->lastInsertId();
                 // Insert Data into Transport Details Table
                 if ($this->hasTransportDetails == 'Yes') {
                     HicreteLogger::logInfo("Inserting into transport details ");
                     $stmtTransportDetails = $dbh->prepare("INSERT INTO inward_transportation_details (inwardid,transportationmode,vehicleno,drivername,transportagency,cost,lchnguserid,lchngtime,creuserid,cretime,remark)\n                       values (:inwardid,:transportationmode,:vehicleno,:drivername,:transportagency,:cost,:lchnguserid,now(),:creuserid,now(),:remark)");
                     $stmtTransportDetails->bindParam(':inwardid', $lastInwardId, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':transportationmode', $this->transportMode, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':vehicleno', $this->vehicleNumber, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':drivername', $this->driverName, PDO::PARAM_STR, 40);
                     $stmtTransportDetails->bindParam(':transportagency', $this->transportAgency, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':cost', $this->transportCost, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':creuserid', $userId, PDO::PARAM_STR, 10);
                     $stmtTransportDetails->bindParam(':remark', $this->remark, PDO::PARAM_STR, 10);
                     HicreteLogger::logDebug("Query: \n" . json_encode($stmtTransportDetails));
                     if ($stmtTransportDetails->execute()) {
                         $lastTransportId = $dbh->lastInsertId();
                         $this->showAlert('success', "Inward details added Successfully!!!");
                         $dbh->commit();
                         //MAP PURCHASE ORDER TO INWARD ENTRY HERE
                     } else {
                         HicreteLogger::logError("Error while adding transport");
                         $this->showAlert('Failure', "Error while adding transport");
                         $dbh->rollBack();
                     }
                 } else {
                     HicreteLogger::logInfo("Inward details added Successfully");
                     $this->showAlert('success', "Inward details added Successfully!!!");
                     $dbh->commit();
                 }
             } else {
                 HicreteLogger::logError("Error while adding 2nd");
                 $this->showAlert('Failure', "Error while adding 2nd");
                 $dbh->rollBack();
             }
         } else {
             HicreteLogger::logError("Error while adding 1st");
             $this->showAlert('Failure', "Error while adding 1st");
             $dbh->rollBack();
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception occured \n" . $e->getMessage());
         echo $e->getMessage();
         $dbh->rollBack();
     }
 }
Ejemplo n.º 10
0
 public function deleteApplicator($data, $userId)
 {
     $db = Database::getInstance();
     $connect = $db->getConnection();
     $applicatorId = $data->applicator_id;
     $stmt1 = $connect->prepare("DELETE FROM `applicator_master` WHERE `applicator_master_id`=:applicatorId");
     $stmt1->bindParam(':applicatorId', $applicatorId);
     if ($stmt1->execute()) {
         HicreteLogger::logInfo("Applicator deleted successfully");
         return true;
     } else {
         HicreteLogger::logError("Could Not Delete Applicator");
         return false;
     }
 }
Ejemplo n.º 11
0
 private static function init()
 {
     self::$klogger = new KLogger("../../logs/log.txt", KLogger::ERROR);
 }
Ejemplo n.º 12
0
 public function updateProduct($dbh, $userId, $productDetails)
 {
     try {
         //BEGIN THE TRANSACTION
         $dbh->beginTransaction();
         $flag = false;
         $updatedProductName = $productDetails->productname;
         $productmasterid = $productDetails->productmasterid;
         HicreteLogger::logInfo("Updating product");
         if ($productDetails->isProductMasterTable) {
             HicreteLogger::logInfo("Updating product master");
             $stmtMasterTable = $dbh->prepare("UPDATE product_master SET productname =:productname,materialtypeid=:materialtypeid,unitofmeasure=:unitofmeasure,lchnguserid=:lchnguserid,lchngtime=now()\n          WHERE productmasterid = :productmasterid");
             $stmtMasterTable->bindParam(':productname', $updatedProductName, PDO::PARAM_STR, 10);
             $stmtMasterTable->bindParam(':materialtypeid', $productDetails->materialtypeid, PDO::PARAM_STR, 10);
             $stmtMasterTable->bindParam(':unitofmeasure', $productDetails->unitofmeasure, PDO::PARAM_STR, 10);
             $stmtMasterTable->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
             $stmtMasterTable->bindParam(':productmasterid', $productmasterid, PDO::PARAM_STR, 10);
             HicreteLogger::logDebug("Query: \n" . json_encode($stmtMasterTable));
             HicreteLogger::logDebug("DATA: \n" . json_encode($productDetails));
             if ($stmtMasterTable->execute()) {
                 // $this->showAlert('success',"Inward details updated Successfully!!!");
                 $flag = true;
             } else {
                 //$this->showAlert('Failure',"Error while adding");
                 $flag = false;
             }
         }
         if ($productDetails->isProductDetailsTable) {
             HicreteLogger::logInfo("Updating product details");
             $stmtDetailsTable = $dbh->prepare("UPDATE product_details SET color =:color,description=:description,alertquantity=:alertquantity,\n          lchnguserid=:lchnguserid,lchngtime=now()\n          WHERE productdetailsid = :productdetailsid");
             $stmtDetailsTable->bindParam(':color', $productDetails->color, PDO::PARAM_STR, 10);
             $stmtDetailsTable->bindParam(':description', $productDetails->description, PDO::PARAM_STR, 10);
             $stmtDetailsTable->bindParam(':alertquantity', $productDetails->alertquantity, PDO::PARAM_STR, 10);
             $stmtDetailsTable->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
             $stmtDetailsTable->bindParam(':productdetailsid', $productDetails->productdetailsid, PDO::PARAM_STR, 10);
             HicreteLogger::logDebug("Query: \n" . json_encode($stmtDetailsTable));
             HicreteLogger::logDebug("DATA: \n" . json_encode($productDetails));
             if ($stmtDetailsTable->execute()) {
                 // $this->showAlert('success',"Inward details updated Successfully!!!");
                 $flag = true;
             } else {
                 //$this->showAlert('Failure',"Error while adding");
                 $flag = false;
             }
         }
         if ($productDetails->isProductPackagingTable) {
             HicreteLogger::logInfo("Updating product packaging");
             $stmtPackagingTable = $dbh->prepare("UPDATE product_packaging SET packaging =:packaging, lchnguserid=:lchnguserid,lchngtime=now()\n          WHERE productpackagingid = :productpackagingid");
             $stmtPackagingTable->bindParam(':packaging', $productDetails->packaging, PDO::PARAM_STR, 10);
             $stmtPackagingTable->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
             $stmtPackagingTable->bindParam(':productpackagingid', $productDetails->productpackagingid, PDO::PARAM_STR, 10);
             HicreteLogger::logDebug("Query: \n" . json_encode($stmtPackagingTable));
             HicreteLogger::logDebug("DATA: \n" . json_encode($productDetails));
             if ($stmtPackagingTable->execute()) {
                 // $this->showAlert('success',"Inward details updated Successfully!!!");
                 $flag = true;
             } else {
                 // $this->showAlert('Failure',"Error while adding");
                 $flag = false;
             }
         }
         if ($productDetails->isProductMaterialTable) {
             HicreteLogger::logInfo("Updating material");
             $stmtMaterialTable = $dbh->prepare("UPDATE material SET abbrevation =:abbrevation, lchnguserid=:lchnguserid,lchngtime=now()\n          WHERE materialid = :materialid");
             $stmtMaterialTable->bindParam(':abbrevation', $productDetails->abbrevation, PDO::PARAM_STR, 10);
             $stmtMaterialTable->bindParam(':lchnguserid', $userId, PDO::PARAM_STR, 10);
             $stmtMaterialTable->bindParam(':materialid', $productDetails->materialid, PDO::PARAM_STR, 10);
             HicreteLogger::logDebug("Query: \n" . json_encode($stmtMaterialTable));
             HicreteLogger::logDebug("DATA: \n" . json_encode($productDetails));
             if ($stmtMaterialTable->execute()) {
                 // $this->showAlert('success',"Inward details updated Successfully!!!");
                 $flag = true;
             } else {
                 // $this->showAlert('Failure',"Error while adding");
                 $flag = false;
             }
         }
         if ($flag) {
             // $this->showAlert('success',"Inward details updated Successfully!!!");
             if ($dbh->commit()) {
                 HicreteLogger::logInfo("Product updated successfully");
                 $this->showAlert('success', "Product Updated Successfully!!!");
             } else {
                 $this->showAlert('success', "Commit failed!!");
             }
         } else {
             HicreteLogger::logError("Error while updating product");
             $this->showAlert('Failure', "Error while Updating");
             $dbh->rollBack();
         }
     } catch (Exception $e) {
         HicreteLogger::logFatal("Exception occured :\n" . $e->getMessage());
         $this->showAlert('Failure', "Exception occured please contact admin");
     }
 }
Ejemplo n.º 13
0
 public static function getCompanyList($userId)
 {
     $db = Database::getInstance();
     $conn = $db->getConnection();
     try {
         $stmt = $conn->prepare("SELECT `companyId` ,`companyName` FROM `companymaster`");
         HicreteLogger::logDebug("Query:\n " . json_encode($stmt));
         if ($stmt->execute()) {
             HicreteLogger::logDebug("Count:\n " . json_encode($stmt->rowCount()));
             $result = $stmt->fetchAll();
             echo AppUtil::getReturnStatus("Successful", $result);
         } else {
             echo AppUtil::getReturnStatus("Failure", "Database Error Occurred");
         }
     } catch (Exceptio $e) {
         echo AppUtil::getReturnStatus("Exception", $e . getMessage());
     }
 }