public function CreateSiteTrackingFollowup($projectId, $data, $userId)
 {
     try {
         if (Followup::CreateSiteTrackingFollowup($projectId, $data, $userId)) {
             echo AppUtil::getReturnStatus("Successful", "Conduction Successful");
         } else {
             echo AppUtil::getReturnStatus("Unsuccessful", "Database Error Occurred");
         }
     } catch (Exception $e) {
         echo AppUtil::getReturnStatus("Unsuccessful", $e->getMessage());
     }
 }
Example #2
0
 public static function saveProject($data, $userId)
 {
     $projnum = AppUtil::generateId();
     $projectBasicDetails = $data->projectDetails;
     $t = time();
     $current = date("Y-m-d", $t);
     $object = array();
     $rollBack = true;
     $db = Database::getInstance();
     $conn = $db->getConnection();
     $conn->beginTransaction();
     $stmt = $conn->prepare("SELECT `ProjectName` FROM `project_master` WHERE `ProjectName`= :projectName");
     $stmt->bindParam(':projectName', $projectBasicDetails->ProjectName, PDO::PARAM_STR);
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if (count($result) > 0) {
         return 2;
     }
     $stmt = $conn->prepare("INSERT INTO project_master (ProjectId, ProjectName, ProjectManagerId, ProjectSource, IsSiteTrackingProject, ProjectStatus, CustomerId, IsClosedProject, isDeleted, CreationDate, CreatedBy, LastModificationDate, LastModifiedBy)\n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
     if ($stmt->execute([$projnum, $projectBasicDetails->ProjectName, $projectBasicDetails->ProjectManagerId, $projectBasicDetails->ProjectSource, '0', 'Initiated', $projectBasicDetails->CustomerId, '0', '0', $current, $userId, $current, $userId]) === TRUE) {
         $stmt2 = $conn->prepare("INSERT INTO project_address_details (ProjectId, Address, City, State, Country, Pincode) VALUES (?,?,?,?,?,?)");
         if ($stmt2->execute([$projnum, $projectBasicDetails->Address, $projectBasicDetails->City, $projectBasicDetails->State, $projectBasicDetails->Country, $projectBasicDetails->Pincode]) === TRUE) {
             $stmt3 = $conn->prepare("INSERT INTO project_point_of_contact_details (ProjectId, PointContactName, MobileNo, LandlineNo, EmailId) VALUES (?,?,?,?,?)");
             if ($stmt3->execute([$projnum, $projectBasicDetails->PointContactName, $projectBasicDetails->MobileNo, $projectBasicDetails->LandlineNo, $projectBasicDetails->EmailId]) === TRUE) {
                 $break = false;
                 foreach ($data->companiesInvolved as $company) {
                     $stmt4 = $conn->prepare("INSERT INTO companies_involved_in_project (ProjectID, CompanyID) VALUES (?,?)");
                     if (!$stmt4->execute([$projnum, $company->companyId])) {
                         throw new Exception($stmt4->errorInfo);
                         $break = true;
                         break;
                     }
                 }
                 if (!$break) {
                     $conn->commit();
                     $rollBack = false;
                     if (isset($data->followupData)) {
                         if (Followup::CreateSiteTrackingFollowup($projnum, $data->followupData, $userId)) {
                             //  echo AppUtil::getReturnStatus("Successful", "Conduction Successful");
                         } else {
                             //  echo AppUtil::getReturnStatus("Unsuccessful", "Database Error Occurred");
                         }
                     }
                 }
             } else {
                 throw new Exception($stmt3->errorInfo);
             }
         } else {
             throw new Exception($stmt2->errorInfo);
         }
     } else {
         throw new Exception($stmt->errorInfo);
     }
     if ($rollBack) {
         $conn->rollBack();
         return 0;
     }
     $conn = null;
     return 1;
 }