function Edit_Company_With_Out_Building($Company_Name, $Company_Name_Amharic, $Category_ID, $Company_Type_ID, $Branch, $Branch_Amharic, $Working_Hours, $Working_Hours_Amharic, $Product_Service, $Product_Service_Amharic, $Registration_Expiration_Date, $Registration_Type, Contact $Contact, Place $place, $Direction, $Direction_Amharic, $Company_ID, $About_Company_ID, $Payment_Status_ID, $Company_Service_ID, $Company_Ownership_ID, $Company_Category_ID, $Contact_ID, $Direction_ID, $Place_ID)
 {
     //contacts
     $Email = $Contact->getEmail();
     $House_No = $Contact->getHouseNo();
     $FAX = $Contact->getFAX();
     $POBOX = $Contact->getPOBOX();
     $Telephone = $Contact->getTelephone();
     //places
     $Region = $place->getRegionID();
     $City = $place->getCityID();
     $Sub_City = $place->getSubCityID();
     $Wereda = $place->getWeredaID();
     $Sefer = $place->getSeferID();
     $Street = $place->getStreetID();
     //start transaction
     $query = "START TRANSACTION";
     mysqli_query($this->getDbc(), $query);
     //1 update the company
     $query1 = "update company\n\t\t\t\t\tset name='{$Company_Name}',name_amharic='{$Company_Name_Amharic}'\n\t\t\t\t\twhere ID='{$Company_ID}'";
     $result1 = mysqli_query($this->getDbc(), $query1);
     //2 udate the about company
     $query2 = "update about_company\n\t\t\t\t\tset branch='{$Branch}',branch_amharic='{$Branch_Amharic}',\n\t\t\t\t\tworking_hours='{$Working_Hours}',working_hours_amharic='{$Working_Hours_Amharic}'\n\t\t\t\t\twhere ID='{$About_Company_ID}'";
     $result2 = mysqli_query($this->getDbc(), $query2);
     //3 update the payment status
     $query3 = "update payment_status\n\t\t\t\t\tset Expiration_Date='{$Registration_Expiration_Date}',Registration_Type='{$Registration_Type}'\n\t\t\t\t\twhere ID='{$Payment_Status_ID}'";
     $result3 = mysqli_query($this->getDbc(), $query3);
     //4 update the company service
     $query4 = "update company_product_service\n\t\t\t\tset Product_Service='{$Product_Service}',Product_Service_Amharic='{$Product_Service_Amharic}'\n\t\t\t\twhere ID='{$Company_Service_ID}'";
     $result4 = mysqli_query($this->getDbc(), $query4);
     //5 update company ownership
     $query5 = "update company_ownership\n\t\t\t\t\tset Ownership_ID='{$Company_Type_ID}'\n\t\t\t\t\twhere ID='{$Company_Ownership_ID}'";
     $result5 = mysqli_query($this->getDbc(), $query5);
     //update company category
     $query6 = "update company_category\n\t\t\t\t\tset Category_ID='{$Category_ID}'\n\t\t\t\t\twhere ID='{$Company_Category_ID}'";
     $result6 = mysqli_query($this->getDbc(), $query6);
     //update the contact
     $query7 = "update contact\n\t\t\t\t\tset Email='{$Email}',House_No='{$House_No}',FAX='{$FAX}',\n\t\t\t\t\tPOBOX='{$POBOX}',Telephone='{$Telephone}'\n\t\t\t\t\twhere ID='{$Contact_ID}'";
     $result3 = mysqli_query($this->getDbc(), $query7);
     //update the direction
     $query8 = "update Direction\n\t\t\t\t\tset Direction='{$Direction}',Direction_Amharic='{$Direction_Amharic}'\n\t\t\t\t\twhere ID='{$Direction_ID}'";
     $result8 = mysqli_query($this->getDbc(), $query8);
     //update the place
     $query9 = "update Place\n\t\t\t\t\tset Region='{$Region}',City='{$City}',Sub_City='{$Sub_City}',\n\t\t\t\t\t\tWereda='{$Wereda}',Sefer='{$Sefer}',Street='{$Street}'\n\t\t\t\t\twhere ID='{$Place_ID}'";
     $result9 = mysqli_query($this->getDbc(), $query9);
     //commit the transaction
     $query_last = "COMMIT";
     mysqli_query($this->getDbc(), $query_last);
     return TRUE;
     echo $Registration_Type;
     exit;
 }
 function Add_Company_With_Out_Building_With_Specialization($Company_Name, $Company_Name_Amharic, $Category_ID, $Company_Type_ID, $Branch, $Branch_Amharic, $Working_Hours, $Working_Hours_Amharic, $Product_Service, $Product_Service_Amharic, $Registration_Expiration_Date, $Registration_Type, Contact $Contact, Place $place, $Direction, $Direction_Amharic, $specialization)
 {
     $query = "START TRANSACTION";
     mysqli_query($this->getDbc(), $query);
     //First add the company
     $query = "INSERT INTO Company (Name,Name_Amharic,Registration_Date) VALUES ('{$Company_Name}','{$Company_Name_Amharic}', Now())";
     $result1 = mysqli_query($this->getDbc(), $query);
     //get the company id
     $added_company_id = $this->getDb()->get_last_id();
     //add company category relation
     $query = "INSERT INTO Company_Category (Company_ID,Category_ID) VALUES('{$added_company_id}','{$Category_ID}')";
     $result2 = mysqli_query($this->getDbc(), $query);
     //add company ownership
     $query = "INSERT INTO Company_Ownership(Company_ID,Ownership_ID)VALUES('{$added_company_id}','{$Company_Type_ID}')";
     $result3 = mysqli_query($this->getDbc(), $query);
     //add about company
     $query = "INSERT INTO About_Company(Company_ID,Branch,Branch_Amharic,Working_Hours,Working_Hours_Amharic) VALUES('{$added_company_id}','{$Branch}','{$Branch_Amharic}','{$Working_Hours}',\n'{$Working_Hours_Amharic}')";
     $result4 = mysqli_query($this->getDbc(), $query);
     //add company service
     $query = "INSERT INTO company_product_service(Company_ID,Product_Service,Product_Service_Amharic) VALUES('{$added_company_id}','{$Product_Service}','{$Product_Service_Amharic}')";
     $result5 = mysqli_query($this->getDbc(), $query);
     //add payment status
     $query = "INSERT INTO Payment_Status(Company_ID,Expiration_Date,Registration_Type) VALUES ('{$added_company_id}','{$Registration_Expiration_Date}','{$Registration_Type}')";
     $result6 = mysqli_query($this->getDbc(), $query);
     //increment address
     $this->Increment_Address(Belong::COMPANY_WITH_OUT_BUILDING);
     //get the address id
     $added_address_id = $this->getDb()->get_last_id();
     //add company address relationship
     $query = "INSERT INTO Company_Address (Company_ID,Address_ID) VALUES('{$added_company_id}','{$added_address_id}')";
     $result7 = mysqli_query($this->getDbc(), $query);
     //add contact
     $Email = $Contact->getEmail();
     $House_No = $Contact->getHouseNo();
     $FAX = $Contact->getFAX();
     $POBOX = $Contact->getPOBOX();
     $Telephone = $Contact->getTelephone();
     $query = "INSERT INTO Contact (Email,House_No,FAX,POBOX,Telephone) VALUES('{$Email}','{$House_No}','{$FAX}','{$POBOX}','{$Telephone}')";
     $result8 = mysqli_query($this->getDbc(), $query);
     //get the contact id
     $added_contact_id = $this->getDb()->get_last_id();
     //add address contact relation
     $query = "INSERT INTO Address_Contact (Address_ID,Contact_ID) VALUES('{$added_address_id}','{$added_contact_id}')";
     $result9 = mysqli_query($this->getDbc(), $query);
     //add place
     $Region_ID = $place->getRegionID();
     $City_ID = $place->getCityID();
     $SubCity_ID = $place->getSubCityID();
     $Wereda_ID = $place->getWeredaID();
     $Sefer_ID = $place->getSeferID();
     $Street_ID = $place->getStreetID();
     $query = "INSERT INTO Place (Region,City,Sub_City,Wereda,Sefer,Street)\n \t\t\t\tVALUE ('{$Region_ID}','{$City_ID}','{$SubCity_ID}','{$Wereda_ID}','{$Sefer_ID}','{$Street_ID}')";
     $result10 = mysqli_query($this->getDbc(), $query);
     //get the id of the added place
     $added_place_id = $this->getDb()->get_last_id();
     //add address place relation
     $query = "INSERT INTO Address_Place (Address_ID,Place_ID) VALUES('{$added_address_id}','{$added_place_id}')";
     $result11 = mysqli_query($this->getDbc(), $query);
     //add direction
     $query = "INSERT INTO Direction (Direction,Direction_Amharic) VALUES('{$Direction}','{$Direction_Amharic}')";
     $result12 = mysqli_query($this->getDbc(), $query);
     $added_direction_id = $this->getDb()->get_last_id();
     //add address direction
     $query = "INSERT INTO Address_Direction (Address_ID,Direction_ID) VALUES('{$added_address_id}','{$added_direction_id}')";
     $result13 = mysqli_query($this->getDbc(), $query);
     $query = "insert into  company_specialization(Company_ID,Spec_1,Spec_2,Spec_3,Spec_4,Spec_5) values('{$added_company_id}',{$specialization['0']},{$specialization['1']},{$specialization['2']},{$specialization['3']},\n{$specialization['4']})";
     $result_spec = mysqli_query($this->getDbc(), $query);
     //        if($result_spec){
     //            echo("The specilization is added");
     //        }
     //        else{
     //            echo("The specliation is not added");
     //
     //            echo($specialization[0]);
     //            echo("-> ");
     //            echo($specialization[1]);
     //            echo("-> ");
     //            echo($specialization[2]);
     //            echo("-> ");
     //            echo($specialization[3]);
     //
     //        }
     if ($result1 and $result2 and $result3 and $result4 and $result5 and $result6 and $result7 and $result8 and $result9 and $result10 and $result11 and $result12 and $result13 and $result_spec) {
         $query = "COMMIT";
         mysqli_query($this->getDbc(), $query);
         return TRUE;
     } else {
         $query = "ROLLBACK";
         mysqli_query($this->getDbc(), $query);
         echo "Rolled back";
         return FALSE;
     }
 }
Пример #3
0
 function Edit_Building(Building $Building, $BUL_ID, Place $Place, $Place_ID, Direction $Dir, $Direction_ID)
 {
     //start the transaction
     $query1 = "START TRANSACTION";
     $result1 = mysqli_query($this->getDbc(), $query1);
     $Building_Name = $Building->getName();
     $Building_Name_Amharic = $Building->getNameAmharic();
     $Building_Description = $Building->getBuildingDescription();
     $Building_Description_Amharic = $Building->getBuildingDescriptionAmharic();
     $Parking_Area = $Building->getParkingArea();
     $Building_ID = $BUL_ID;
     //now edit the company;
     $query2 = "Update Building set\n\t\tName='{$Building_Name}',Name_Amharic = '{$Building_Name_Amharic}'\n\t\t,Building_Description='{$Building_Description}'\n\t\t,Building_Description_Amharic='{$Building_Description_Amharic}',\n\t\tParking_Area='{$Parking_Area}' where ID='{$Building_ID}'";
     $result2 = mysqli_query($this->getDbc(), $query2);
     if ($result2) {
         echo "result 2";
     }
     //edit the place
     $Region_ID = $Place->getRegionID();
     $City_ID = $Place->getCityID();
     $Sub_City_ID = $Place->getSubCityID();
     $Wereda_ID = $Place->getWeredaID();
     $Sefer_ID = $Place->getSeferID();
     $Street_ID = $Place->getStreetID();
     $query3 = "update place set\n\t\t\t\tRegion='{$Region_ID}',City='{$City_ID}',Sub_City='{$Sub_City_ID}',Wereda='{$Wereda_ID}',Sefer='{$Sefer_ID}',Street='{$Street_ID}'\n\t\t\t\twhere ID='{$Place_ID}'";
     $result3 = mysqli_query($this->getDbc(), $query3);
     if ($result3) {
         echo "result 3";
     }
     //update direction
     $Direction = $Dir->getDirection();
     $Direction_Amharic = $Dir->getDirectionAmharic();
     $query4 = "update direction set\n\t\t\t\t\tDirection='{$Direction}',Direction_Amharic='{$Direction_Amharic}'\n\t\t\t\t\twhere ID='{$Direction_ID}'";
     $result4 = mysqli_query($this->getDbc(), $query4);
     if ($result4) {
         echo "result 4";
     }
     if ($result1 and $result2 and $result3 and $result4) {
         $query_last = "COMMIT";
         mysqli_query($this->getDbc(), $query_last);
         return TRUE;
     } else {
         $query_last = "ROLLBACK";
         mysqli_query($this->getDbc(), $query_last);
         return FALSE;
     }
 }