Skip to content

Commit

Permalink
Add new field in structure and fix json bookings
Browse files Browse the repository at this point in the history
- Add taxNumber in structure model and UI
- Add new footer in invoice pdf
- Fix findAllBookingsJson with a new action
  • Loading branch information
alberto committed May 9, 2013
1 parent 809cd4b commit 7f0b32a
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 34 deletions.
2 changes: 2 additions & 0 deletions solr/structure/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<field name="fax" type="string" indexed="true" stored="false" multiValued="false" />
<field name="email" type="string" indexed="true" stored="false" multiValued="false" />
<field name="url" type="string" indexed="true" stored="false" multiValued="false" />
<field name="taxNumber" type="string" indexed="true" stored="false" multiValued="false" />
<field name="notes" type="string" indexed="true" stored="false" multiValued="false" />
<field name="id_user" type="int" indexed="true" stored="false" multiValued="false" />
<field name="text" type="text_general" indexed="true" stored="true" multiValued="true" />
Expand All @@ -65,5 +66,6 @@
<copyField source="fax" dest="text"/>
<copyField source="email" dest="text"/>
<copyField source="url" dest="text"/>
<copyField source="taxNumber" dest="text"/>
<copyField source="notes" dest="text"/>
</schema>
1 change: 1 addition & 0 deletions sql/locanda.sql
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ CREATE TABLE `structure` (
`notes` varchar(255) DEFAULT NULL,
`id_user` int(11) DEFAULT NULL,
`mobile` varchar(255) DEFAULT NULL,
`taxNumber` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand Down
18 changes: 10 additions & 8 deletions src/action/BookingAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class BookingAction extends ActionSupport implements SessionAware,UserAwa
private Double adjustmentsSubtotal = 0.0;
private Double paymentsSubtotal = 0.0;
private Integer idStructure;
private String dateStart = null;
private String start = null;
private List<Integer> listNumGuests = null;
@Autowired
private ExtraService extraService = null;
Expand Down Expand Up @@ -606,10 +606,12 @@ public String findAllBookings(){
})
})
public String findAllBookingsByStartDateAndLengthOfStay(){
if (this.getDateStart() != null && this.getDateStart().length() > 1) {
Date startDateBookings = new Date(Long.parseLong(this.getDateStart()));
this.setBookings(this.getBookingService().findBookingsByIdStructure(this.getIdStructure()));

if (this.getStart() != null && this.getStart().length() > 1) {
Date startDateBookings = new Date(Long.parseLong(this.getStart()) * 1000);
logger.info("**** data inizio2 ***" + startDateBookings);
this.setBookings(this.getBookingService().findAllBookingsByStartDateAndLengthOfStay(this.getIdStructure(), startDateBookings, 10));
return SUCCESS;
}
return ERROR;

Expand Down Expand Up @@ -1037,12 +1039,12 @@ public void setCreditCardService(CreditCardService creditCardService) {
this.creditCardService = creditCardService;
}

public String getDateStart() {
return dateStart;
public String getStart() {
return start;
}

public void setDateStart(String dateStart) {
this.dateStart = dateStart;
public void setStart(String start) {
this.start = start;
}

}
2 changes: 2 additions & 0 deletions src/global_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ subtotalRoom = Subtotal for the Room

sunday = Sunday

taxNumber = VAT

thisFileMandatory = This Field is Mandatory

thursday = Thursday
Expand Down
2 changes: 2 additions & 0 deletions src/global_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ subtotalRoom = Subtotal por habitaci\u00F3n

sunday = Domingo

taxNumber = CIF/NIF

thisFileMandatory = campo obligatorio

thursday = Jueves
Expand Down
2 changes: 2 additions & 0 deletions src/global_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ subtotalRoom = Costo per la camera

sunday = Domenica

taxNumber = P.IVA/CF

thisFileMandatory = campo obbligatorio

thursday = Gioved\u00EC
Expand Down
8 changes: 8 additions & 0 deletions src/model/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class Structure implements Serializable {
private Integer id_user;
@Field
private String mobile;
@Field
private String taxNumber;

private List<Image> images;
private List<Facility> facilities;
Expand Down Expand Up @@ -150,6 +152,12 @@ public String getMobile() {
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getTaxNumber() {
return taxNumber;
}
public void setTaxNumber(String taxNumber) {
this.taxNumber = taxNumber;
}


}
6 changes: 3 additions & 3 deletions src/persistence/mybatis/mappers/StructureMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ In case of controversy the competent court is the Court of Cagliari (Italy).

<update id="updateStructure" parameterType="model.Structure">
UPDATE structure
set name= #{name},email= #{email},url= #{url},phone= #{phone},fax= #{fax},address= #{address},city= #{city},country= #{country},zipCode= #{zipCode},notes= #{notes},id_user= #{id_user},mobile= #{mobile}
set name= #{name},email= #{email},url= #{url},phone= #{phone},fax= #{fax},address= #{address},city= #{city},country= #{country},zipCode= #{zipCode},notes= #{notes},id_user= #{id_user},mobile= #{mobile},taxNumber= #{taxNumber}
WHERE id = #{id}
</update>

<insert id="insertStructure" useGeneratedKeys="true" keyProperty="id" parameterType="model.Structure">
INSERT INTO
structure(name,email,url,phone,fax,address,city,country,zipCode,notes,id_user)
values(#{name}, #{email}, #{url}, #{phone}, #{fax}, #{address}, #{city}, #{country}, #{zipCode}, #{notes}, #{id_user}, #{mobile})
values(#{name}, #{email}, #{url}, #{phone}, #{fax}, #{address}, #{city}, #{country}, #{zipCode}, #{notes}, #{id_user}, #{mobile}, #{taxNumber})
</insert>

<sql id="selectStructure">
SELECT id,name,email,url,phone,fax,address,city,country,zipCode,notes,id_user,mobile FROM structure
SELECT id,name,email,url,phone,fax,address,city,country,zipCode,notes,id_user,mobile,taxNumber FROM structure
</sql>

</mapper>
2 changes: 2 additions & 0 deletions src/service/BookingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ public interface BookingService {
public Integer updateBooking(Booking booking);
public Integer deleteBooking(Integer id);

Boolean checkifExistBookingInRangeOfDates(Booking booking, Date startDate, Date endDate);

}
35 changes: 33 additions & 2 deletions src/service/BookingServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import model.listini.Season;
import model.questura.HousedExport;

import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -125,8 +126,38 @@ public List<Integer> findBookingIdsByIdStructure(Integer id_structure) {
@Override
public List<Booking> findAllBookingsByStartDateAndLengthOfStay(
Integer id_structure, Date startDate, Integer lengthOfStay) {
// TODO Auto-generated method stub
return null;
List<Booking> bookings = null;
Booking booking = null;
Date endDate = DateUtils.addDays(startDate, lengthOfStay);

bookings = new ArrayList<Booking>();
for(Integer id: this.getBookingMapper().findBookingIdsByIdStructure(id_structure)){
booking = this.findBookingById(id);
if(this.checkifExistBookingInRangeOfDates(booking, startDate, endDate)){
bookings.add(booking);
}

}
return bookings;
}

@Override
public Boolean checkifExistBookingInRangeOfDates(Booking booking, Date startDate, Date endDate){
// dateIn|---------------------------------------------------------------------------------------------------------| dateOut
// dateIn|-------------------------| dateOut dateIn |-----|dateOut dateIn |------------| dateOut
// startDate|----------------------------------------------------------------------------|endDate
//
if(booking.getDateOut().after(endDate) && booking.getDateIn().compareTo(startDate)<=0){
return true;
}
if(booking.getDateOut().compareTo(endDate) <=0 && (booking.getDateOut().compareTo(startDate)>= 0 ) ){
return true;
}
if(booking.getDateIn().compareTo(startDate)>=0 && booking.getDateIn().compareTo(endDate)<=0){
return true;
}

return false;
}

@Override
Expand Down
32 changes: 20 additions & 12 deletions webroot/WEB-INF/jsp/templates/structure.mustache.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,40 @@
{{#availableCountries}}<option value="{{code}}" {{#selected}}selected="selected"{{/selected}}>{{name}}</option>{{/availableCountries}}
</select>
</div>
<div class="type-text">
<label for="FormEmail"><s:text name="email"/><sup title="<s:text name="thisFileMandatory"/>.">*</sup></label>
<input type="text" class="required email" name="email" id="FormEmail" value="{{email}}" aria-required="true" size="20" />
</div>
<div class="type-button">
<button class="btn_save"><s:text name="save"/></button>
<button class="btn_reset btn_cancel_form"><s:text name="cancel"/></button>
</div>
</div>
<div class="c50l">
<div class="type-text">
<label for="FormEmail"><s:text name="email"/><sup title="<s:text name="thisFileMandatory"/>.">*</sup></label>
<input type="text" class="required email" name="email" id="FormEmail" value="{{email}}" aria-required="true" size="20" />
</div>
<div class="type-text">
<label for="FormUrl"><s:text name="url"/></label>
<input type="text" name="url" id="FormUrl" value="{{url}}" aria-required="true" />
<label for="FormUrl"><s:text name="url"/></label>
<input type="text" name="url" id="FormUrl" value="{{url}}" aria-required="true" />
</div>
<div class="type-text">
<label for="FormPhone"><s:text name="phone"/><sup title="<s:text name="thisFileMandatory"/>.">*</sup></label>
<input type="text" class="required validPhone" name="phone" id="FormPhone" value="{{phone}}" aria-required="true" />
<input type="text" class="required validPhone" name="phone" id="FormPhone" value="{{phone}}" aria-required="true" />
</div>
<div class="type-text">
<label for="FormMobile"><s:text name="mobile"/></label>
<input type="text" class="validPhone" name="mobile" id="FormMobile" value="{{mobile}}" />
</div>
<div class="type-text">
<label for="FormFax"><s:text name="fax"/></label>
<input type="text" class="validPhone" name="fax" id="FormFax" value="{{fax}}" aria-required="true" />
<input type="text" class="validPhone" name="fax" id="FormFax" value="{{fax}}" aria-required="true" />
</div>
<div class="type-text">
<label for="FormTaxNumber"><s:text name="taxNumber"/></label>
<input type="text" name="taxNumber" id="FormTaxNumber" value="{{taxNumber}}" />
</div>
<div class="type-text">
<label for="FormNotes"><s:text name="notes"/></label>
<textarea name="notes" id="FormNotes">{{notes}}</textarea>
</div>
</div>
</div>
</form>

Expand Down Expand Up @@ -124,12 +128,12 @@
<strong><s:text name="country"/>:</strong>
<span>{{country}}</span>
</div>
</div>
<div class="c50l">
<div class="type-text">
<strong><s:text name="email"/>:</strong>
<span>{{email}}</span>
</div>
</div>
</div>
<div class="c50l">
<div class="type-text">
<strong><s:text name="url"/>:</strong>
<span>{{url}}</span>
Expand All @@ -145,6 +149,10 @@
<div class="type-text">
<strong><s:text name="fax"/>:</strong>
<span>{{fax}}</span>
</div>
<div class="type-text">
<strong><s:text name="taxNumber"/>:</strong>
<span>{{fax}}</span>
</div>
<div class="type-text">
<strong><s:text name="notes"/>:</strong>
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/views/planner.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ $(function () {
eventMouseover: function (calEvent, $event) {},
eventMouseout: function (calEvent, $event) {},
noEvents: function () {},
data: "findAllBookingsJson.action"
data: "findAllBookingsByStartDateAndLengthOfStay.action"
});
},
/**
Expand Down
Loading

0 comments on commit 7f0b32a

Please sign in to comment.