public static function updateBillStatus($data, $userId) { $db = Database::getInstance(); $conn = $db->getConnection(); $billId = $data->billId; $status = $data->status; try { $stmt = $conn->prepare("UPDATE unapproved_expense_bills SET\n lastmodificationdate=NOW(),\n lastmodifiedby=:modifiedBy,\n bill_status=:status\n WHERE\n billid=:billId\n "); $stmt->bindParam(':modifiedBy', $userId); $stmt->bindParam(':status', $status); $stmt->bindParam(':billId', $billId); HicreteLogger::logDebug("Query: \n" . json_encode($stmt)); if ($stmt->execute()) { HicreteLogger::logDebug("Row count: \n" . json_encode($stmt->rowCount())); echo AppUtil::getReturnStatus("success", "Bill Status Updated Successfully"); } else { echo AppUtil::getReturnStatus("failure", "Bill Status Could Not Update"); } } catch (Exception $e) { HicreteLogger::logFatal("Exception Occured Message:\n" . $e->getMessage()); echo "Exception Occur While Updating Bill Status"; } }
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()); } }
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"); } }
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; } }
$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'];
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(); } }
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()); } }
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(); } }
public function modifyApplicatorDetails($data, $userId) { try { $db = Database::getInstance(); $connect = $db->getConnection(); HicreteLogger::logInfo("modifying applicator"); $applicatorMasterId = $data->applicator_master_id; $applicatorName = $data->applicator_name; $applicatorContactNo = $data->applicator_contact; $applicatorAddressLine1 = $data->applicator_address_line1; $applicatorAddressLine2 = $data->applicator_address_line2; $applicatorCountry = $data->applicator_country; $applicatorState = $data->applicator_state; $applicatorCity = $data->applicator_city; $applicatorVatNumber = $data->applicator_vat_number; $applicatorCstNumber = $data->applicator_cst_number; $applicatorServiceTaxNumber = $data->applicator_stax_number; $applicatorPanNumber = $data->applicator_pan_number; $pointOfContact = $data->point_of_contact; $pointContactNo = $data->point_of_contact_no; $stmt1 = $connect->prepare("UPDATE applicator_master SET\n applicator_name=:applicatorName,\n applicator_contact=:applicatorContactNo,\n applicator_contact=:applicatorContactNo,\n applicator_address_line1=:applicatorAddressLine1,\n applicator_address_line2=:applicatorAddressLine2,\n applicator_city=:applicatorCity,\n applicator_state=:applicatorState,\n applicator_country=:applicatorCountry,\n applicator_vat_number=:vatNumber,\n applicator_cst_number=:cstNumber,\n applicator_stax_number=:staxNumber,\n applicator_pan_number=:panNumber,\n last_modified_by=:lastModifiedBy\n WHERE applicator_master_id=:applicatorMasterId"); $stmt1->bindParam(':applicatorMasterId', $applicatorMasterId); $stmt1->bindParam(':applicatorName', $applicatorName); $stmt1->bindParam(':applicatorContactNo', $applicatorContactNo); $stmt1->bindParam(':applicatorAddressLine1', $applicatorAddressLine1); $stmt1->bindParam(':applicatorAddressLine2', $applicatorAddressLine2); $stmt1->bindParam(':applicatorCity', $applicatorCity); $stmt1->bindParam(':applicatorState', $applicatorState); $stmt1->bindParam(':applicatorCountry', $applicatorCountry); $stmt1->bindParam(':vatNumber', $applicatorVatNumber); $stmt1->bindParam(':cstNumber', $applicatorCstNumber); $stmt1->bindParam(':staxNumber', $applicatorServiceTaxNumber); $stmt1->bindParam(':panNumber', $applicatorPanNumber); $stmt1->bindParam(':lastModifiedBy', $userId); $stmt2 = $connect->prepare("UPDATE applicator_pointof_contact SET\n point_of_contact=:pointOfContact,\n point_of_contact_no=:pointContactNo,\n last_modified_by=:lastModifiedBy\n WHERE applicator_master_id=:applicatorMasterId\n "); $stmt2->bindParam(':applicatorMasterId', $applicatorMasterId); $stmt2->bindParam(':pointOfContact', $pointOfContact); $stmt2->bindParam(':pointContactNo', $pointContactNo); $stmt2->bindParam(':lastModifiedBy', $userId); HicreteLogger::logDebug("Query:\n " . json_encode($stmt1)); HicreteLogger::logDebug("Data:\n " . json_encode($data)); if ($stmt1->execute()) { HicreteLogger::logDebug("Query:\n " . json_encode($stmt2)); if ($stmt2->execute()) { HicreteLogger::logInfo("Applicator modified successfully"); return true; } else { HicreteLogger::logError("Applicator not modified successfully"); return false; } } else { return false; } } catch (Exception $e) { HicreteLogger::logFatal("Exception Occured Message:\n" . $e->getMessage()); return false; } }
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"); } }
public static function modifyUserDetails($data) { try { HicreteLogger::logInfo("Modifying user"); $db = Database::getInstance(); $conn = $db->getConnection(); $conn->beginTransaction(); $date = new DateTime($data->userInfo->newDate); $dob = $date->format('Y-m-d'); $userId = $data->userInfo->userId; $stmt = $conn->prepare("UPDATE usermaster SET firstName=:firstName,\n lastName=:lastName,dateOfBirth=:dateOfBirth,address=:address,city=:city,state=:state,country=:country,pincode=:pincode,mobileNumber=:mobileNumber,lastModifiedBy=:lastModifiedBy,lastModificationDate=now(),profilePicPath=:profilePicPath WHERE userId = :userId"); $stmt->bindParam(':firstName', $data->userInfo->firstName, PDO::PARAM_STR); $stmt->bindParam(':lastName', $data->userInfo->lastName, PDO::PARAM_STR); $stmt->bindParam(':dateOfBirth', $dob, PDO::PARAM_STR); $stmt->bindParam(':address', $data->userInfo->address, PDO::PARAM_STR); $stmt->bindParam(':city', $data->userInfo->city, PDO::PARAM_STR); $stmt->bindParam(':state', $data->userInfo->state, PDO::PARAM_STR); $stmt->bindParam(':country', $data->userInfo->country, PDO::PARAM_STR); $stmt->bindParam(':pincode', $data->userInfo->pincode, PDO::PARAM_STR); $stmt->bindParam(':mobileNumber', $data->userInfo->mobileNumber, PDO::PARAM_STR); $stmt->bindParam(':lastModifiedBy', $userId, PDO::PARAM_STR); $stmt->bindParam(':userId', $userId, PDO::PARAM_STR); $stmt->bindParam(':profilePicPath', $data->userInfo->profilePic, PDO::PARAM_STR); HicreteLogger::logDebug("Query:\n " . json_encode($stmt)); HicreteLogger::logDebug("Data:\n " . json_encode($data)); if ($stmt->execute()) { $conn->commit(); HicreteLogger::logInfo("Profile modified successfully"); echo "Profile Modified successfully"; } else { HicreteLogger::logError("Failure in updating user details"); echo "Something went wrong.Please try again"; } } catch (Exception $e) { HicreteLogger::logFatal("Exception Occured Message:\n" . $e->getMessage()); echo $e->getMessage(); } }