Beispiel #1
0
 public function reviseQuotation($qid, $data)
 {
     $db = Database::getInstance();
     $conn = $db->getConnection();
     $conn->beginTransaction();
     try {
         $stmt1 = $conn->prepare("DELETE FROM quotation_tax_applicable_to  WHERE TaxID IN (SELECT TaxID FROM quotation_tax_details  WHERE QuotationId = :qid)");
         $stmt1->bindParam(':qid', $qid, PDO::PARAM_STR);
         if ($stmt1->execute() === TRUE) {
             $stmt2 = $conn->prepare("DELETE FROM quotation_tax_details  WHERE QuotationId = :qid");
             $stmt2->bindParam(':qid', $qid, PDO::PARAM_STR);
             if ($stmt2->execute() === TRUE) {
                 $stmt3 = $conn->prepare("DELETE FROM quotation_details  WHERE QuotationId = :qid");
                 $stmt3->bindParam(':qid', $qid, PDO::PARAM_STR);
                 if ($stmt3->execute() === TRUE) {
                     if (Quotation::isRefNoPresentInAnotherQuotation($data->Quotation->RefNo, $qid)) {
                         $conn->rollback();
                         return 2;
                     }
                     if (Quotation::isQuotationTitlePresentInAnotherQuotation($data->Quotation->ProjectId, $data->Quotation->QuotationTitle, $qid)) {
                         $conn->rollback();
                         return 3;
                     }
                     $result = Quotation::modifyQuotation($data, $qid);
                     if ($result) {
                         $conn->commit();
                         return 1;
                     }
                 }
             }
         }
     } catch (Exception $exception) {
         $conn->rollBack();
         throw $exception;
     }
     $conn->rollback;
     return 0;
 }