PageSourceSearch

https://www.tvaruzky.cz/wp-content/plugins/booking-system/assets/j…/frontend-discounts.js?ver=2.9.9.6.9

js tvaruzky.cz collected 2026-09-24 20:30:32 UTC 12,102 bytes, 322 lines download raw bytes

1/*
2* Title                   : Pinpoint Booking System WordPress Plugin (PRO)
3* Version                 : 2.1.7
4* File                    : assets/js/discounts/frontend-discounts.js
5* File Version            : 1.0.1
6* Created / Last Modified : 23 February 2016
7* Author                  : Dot on Paper
8* Copyright               : © 2012 Dot on Paper
9* Website                 : http://www.dotonpaper.net
10* Description             : Front end discounts JavaScript class.
11*/
12
13var DOPBSPFrontEndDiscounts = new function(){
14    'use strict';
15
16    /*
17     * Constructor
18     */
19    this.__construct = function(){
20    };
21
22    /*
23     * Get discount data.
24     * 
25     * @param ID (Number): calendar ID
26     * @param ciDay (String): check in day
27     * @param ciDay (String): check in day
28     * @param startHour (String): start hour
29     * @param endHour (String): start hour
30     * 
31     * @retun discount data
32     */
33    this.get = function(ID,
34                        ciDay,
35                        coDay,
36                        startHour,
37                        endHour){
38        var dataDays      = DOPBSPFrontEnd.calendar[ID]['days']['data'],
39            dataDiscounts = DOPBSPFrontEnd.calendar[ID]['discounts']['data'],
40            dataHours     = DOPBSPFrontEnd.calendar[ID]['hours']['data'],
41            discount      = {
42                'id'         : 0,
43                'rule_id'    : 0,
44                'operation'  : '-',
45                'price'      : 0,
46                'price_type' : 'percent',
47                'price_by'   : 'once',
48                'start_date' : '',
49                'end_date'   : '',
50                'start_hour' : '',
51                'end_hour'   : '',
52                'translation': ''
53            },
54            discounts     = dataDiscounts['discount'],
55            i,
56            j,
57            rule,
58            ruleFound,
59            timeLapse;
60
61        /*
62         * Verify days/hours.
63         */
64        coDay = coDay === ''
65                ? ciDay
66                : coDay;
67        endHour = endHour === ''
68                ? startHour
69                : endHour;
70
71        /*
72         * Calculate time lapse.
73         */
74        timeLapse = dataHours['enabled']
75                ? DOPPrototypes.getHoursDifference(startHour,
76                                                   endHour,
77                                                   'hours')
78                +(dataHours['addLastHourToTotalPrice']
79                        ? 0
80                        : 0)
81                : DOPPrototypes.getNoDays(ciDay,
82                                          coDay)
83                -(dataDays['morningCheckOut']
84                        ? 1
85                        : 0);
86
87        if (dataHours['enabled']
88                && dataHours['interval_autobreak']){
89
90            if (timeLapse%2 === 0){
91                timeLapse = parseInt(timeLapse/2);
92            }
93            else{
94                timeLapse = parseInt(timeLapse/2)+1;
95            }
96        }
97
98        for (i = 0; i<discounts.length; i++){
99            if ((discounts[i]['start_time_lapse'] === ''
100                    || parseFloat(discounts[i]['start_time_lapse'])<=timeLapse)
101                    && (discounts[i]['end_time_lapse'] === ''
102                            || parseFloat(discounts[i]['end_time_lapse'])>=timeLapse)){
103                discount['id'] = discounts[i]['id'];
104                discount['operation'] = discounts[i]['operation'];
105                discount['price'] = discounts[i]['price'];
106                discount['price_by'] = discounts[i]['price_by'];
107                discount['price_type'] = discounts[i]['price_type'];
108                discount['translation'] = discounts[i]['translation'];
109
110                for (j = 0; j<discounts[i]['rules'].length; j++){
111                    rule = discounts[i]['rules'][j];
112                    ruleFound = false;
113
114                    if ((rule['start_date'] === ''
115                            || rule['start_date']<=ciDay)
116                            && (rule['end_date'] === ''
117                                    || rule['end_date']>=coDay)){
118                        if (dataHours['enabled']){
119                            if ((rule['start_hour'] === ''
120                                    || rule['start_hour']<=startHour)
121                                    && (rule['end_hour'] === ''
122                                            || rule['end_hour']>=endHour)){
123                                ruleFound = true;
124                            }
125                        }
126                        else{
127                            ruleFound = true;
128                        }
129                    }
130
131                    if (ruleFound){
132                        discount['rule_id'] = rule['id'];
133                        discount['operation'] = rule['operation'];
134                        discount['price'] = rule['price'];
135                        discount['price_by'] = rule['price_by'];
136                        discount['price_type'] = rule['price_type'];
137                        discount['start_date'] = rule['start_date'];
138                        discount['end_date'] = rule['end_date'];
139
140                        break;
141                    }
142                }
143
144                if (discounts[i]['rules'].length === 0
145                        && discounts[i]['price'] !== 0
146                        || ruleFound){
147                    break;
148                }
149            }
150        }
151
152        return discount;
153    };
154
155    /*
156     * Get discount value.
157     * 
158     * @param ID (Number): calendar ID
159     * @param discount (Object): discount data
160     * @param reservationPrice (Number): reservation price
161     * @param extrasPrice (Number): extras price
162     * @param ciDay (String): check in day
163     * @param ciDay (String): check in day
164     * @param startHour (String): start hour
165     * @param endHour (String): start hour
166     * @param noItems (Number): number of reserved items
167     * 
168     * @retun discount price value
169     */
170    this.getPrice = function(ID,
171                             discount,
172                             reservationPrice,
173                             extrasPrice,
174                             ciDay,
175                             coDay,
176                             startHour,
177                             endHour,
178                             noItems){
179        var dataDays      = DOPBSPFrontEnd.calendar[ID]['days']['data'],
180            dataDiscounts = DOPBSPFrontEnd.calendar[ID]['discounts']['data'],
181            dataHours     = DOPBSPFrontEnd.calendar[ID]['hours']['data'],
182            timeLapse;
183
184        /*
185         * Verify days/hours.
186         */
187        coDay = coDay === ''
188                ? ciDay
189                : coDay;
190        endHour = endHour === ''
191                ? startHour
192                : endHour;
193
194        /*
195         * Calculate price.
196         */
197        timeLapse = dataHours['enabled']
198                ? DOPPrototypes.getHoursDifference(startHour,
199                                                   endHour,
200                                                   'hours')+(dataHours['addLastHourToTotalPrice']
201                ? 1
202                : 0)
203                :
204                DOPPrototypes.getNoDays(ciDay,
205                                        coDay)-(dataDays['morningCheckOut']
206                ? 1
207                : 0);
208
209        return (discount['operation'] === '-'
210                ? -1
211                : 1)
212                *(discount['price_by'] === 'once'
213                        ? 1
214                        : timeLapse)
215                *discount['price']
216                *(discount['price_type'] === 'fixed'
217                        ? noItems
218                        : (reservationPrice+(dataDiscounts['extras']
219                                ? extrasPrice
220                                : 0)))/
221                (discount['price_type'] === 'fixed'
222                        ? 1
223                        : 100);
224    };
225
226    /*
227     * Set discount details.
228     * 
229     * @param ID (Number): calendar ID
230     * @param discount (Object): discount data
231     * @param reservationPrice (Number): reservation price
232     * @param extrasPrice (Number): extras price
233     * @param ciDay (String): check in day
234     * @param ciDay (String): check in day
235     * @param startHour (String): start hour
236     * @param endHour (String): start hour
237     * @param noItems (Number): number of reserved items
238     * 
239     * @retun HTML
240     */
241    this.set = function(ID,
242                        discount,
243                        reservationPrice,
244                        extrasPrice,
245                        ciDay,
246                        coDay,
247                        startHour,
248                        endHour,
249                        noItems){
250        var dataHours = DOPBSPFrontEnd.calendar[ID]['hours']['data'],
251            HTML      = [],
252            price;
253
254        /*
255         * Verify days/hours.
256         */
257        coDay = coDay === ''
258                ? ciDay
259                : coDay;
260        endHour = endHour === ''
261                ? startHour
262                : endHour;
263
264        if (discount['price']>0){
265            price = DOPBSPFrontEndDiscounts.getPrice(ID,
266                                                     discount,
267                                                     reservationPrice,
268                                                     extrasPrice,
269                                                     ciDay,
270                                                     coDay,
271                                                     startHour,
272                                                     endHour,
273                                                     noItems);
274
275            if (price !== 0){
276                HTML.push(' <tr class="dopbsp-separator">');
277                HTML.push('     <td class="dopbsp-label"><div class="dopbsp-line"></div></td>');
278                HTML.push('     <td class="dopbsp-value"><div class="dopbsp-line"></div></td>');
279                HTML.push(' </tr>');
280                HTML.push(' <tr>');
281                HTML.push('     <td class="dopbsp-label">'+DOPBSPFrontEnd.text(ID,
282                                                                               'discounts',
283                                                                               'title')+'</td>');
284                HTML.push('     <td class="dopbsp-value dopbsp-info">');
285                HTML.push('         '+discount['translation']+'<br />');
286
287                if (discount['price_type'] !== 'fixed'
288                        || discount['price_by'] !== 'once'){
289                    HTML.push('         <span class="dopbsp-info-rule">&#9632;&nbsp;');
290
291                    if (discount['price_type'] === 'fixed'){
292                        HTML.push(discount['operation']+DOPBSPFrontEnd.setPrice(ID,
293                                                                                discount['price']));
294                    }
295                    else{
296                        HTML.push(discount['operation']+discount['price']+'%');
297                    }
298
299                    if (discount['price_by'] !== 'once'){
300                        HTML.push('/'+(dataHours['enabled']
301                                ? DOPBSPFrontEnd.text(ID,
302                                                      'discounts',
303                                                      'byHour')
304                                : DOPBSPFrontEnd.text(ID,
305                                                      'discounts',
306                                                      'byDay')));
307                    }
308                    HTML.push('         </span><br />');
309                }
310                HTML.push('         <span class="dopbsp-info-price">'+discount['operation']+'&nbsp;'+DOPBSPFrontEnd.setPrice(ID,
311                                                                                                                             price)+'</span>');
312
313                HTML.push('     </td>');
314                HTML.push(' </tr>');
315            }
316        }
317
318        return HTML.join('');
319    };
320
321    return this.__construct();
322};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.