|  | @@ -35,6 +35,7 @@
 | 
	
		
			
				|  |  |      stock_count;
 | 
	
		
			
				|  |  |      barcode;
 | 
	
		
			
				|  |  |      thumbnail;
 | 
	
		
			
				|  |  | +    on_stock;
 | 
	
		
			
				|  |  |      constructor(target) {
 | 
	
		
			
				|  |  |        this.name = null;
 | 
	
		
			
				|  |  |        this.description = null;
 | 
	
	
		
			
				|  | @@ -43,6 +44,7 @@
 | 
	
		
			
				|  |  |        this.stock_count = null;
 | 
	
		
			
				|  |  |        this.barcode = null;
 | 
	
		
			
				|  |  |        this.thumbnail = null;
 | 
	
		
			
				|  |  | +      this.on_stock = null;
 | 
	
		
			
				|  |  |        if ("name" in target) this.name = target["name"];
 | 
	
		
			
				|  |  |        if ("description" in target) this.description = target["description"];
 | 
	
		
			
				|  |  |        if ("author" in target) this.author = target["author"];
 | 
	
	
		
			
				|  | @@ -50,9 +52,10 @@
 | 
	
		
			
				|  |  |        if ("stock_count" in target) this.stock_count = target["stock_count"];
 | 
	
		
			
				|  |  |        if ("barcode" in target) this.barcode = target["barcode"];
 | 
	
		
			
				|  |  |        if ("thumbnail" in target) this.thumbnail = target["thumbnail"];
 | 
	
		
			
				|  |  | +      if ("on_stock" in target) this.on_stock = target["on_stock"];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      get dump() {
 | 
	
		
			
				|  |  | -      return {
 | 
	
		
			
				|  |  | +      const dumped = {
 | 
	
		
			
				|  |  |          "name": this.name,
 | 
	
		
			
				|  |  |          "description": this.description,
 | 
	
		
			
				|  |  |          "author": this.author,
 | 
	
	
		
			
				|  | @@ -61,6 +64,10 @@
 | 
	
		
			
				|  |  |          "barcode": this.barcode,
 | 
	
		
			
				|  |  |          "thumbnail": this.thumbnail
 | 
	
		
			
				|  |  |        };
 | 
	
		
			
				|  |  | +      if (this.on_stock !== null) {
 | 
	
		
			
				|  |  | +        dumped["on_stock"] = this.on_stock;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      return dumped;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      get ready() {
 | 
	
		
			
				|  |  |        if (this.name === null || this.description === null) return false;
 | 
	
	
		
			
				|  | @@ -325,6 +332,9 @@
 | 
	
		
			
				|  |  |      _action() {
 | 
	
		
			
				|  |  |        throw new TypeError("It must be overwriten.");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    get _info() {
 | 
	
		
			
				|  |  | +      return false;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      show() {
 | 
	
		
			
				|  |  |        if (this.#node !== null) {
 | 
	
		
			
				|  |  |          return;
 | 
	
	
		
			
				|  | @@ -378,21 +388,23 @@
 | 
	
		
			
				|  |  |        cancel_button.classList.add("material-icons");
 | 
	
		
			
				|  |  |        cancel_button.innerText = "clear";
 | 
	
		
			
				|  |  |        buttons.appendChild(cancel_button);
 | 
	
		
			
				|  |  | -      const confirm_button = document.createElement("button");
 | 
	
		
			
				|  |  | -      confirm_button.classList.add("confirm");
 | 
	
		
			
				|  |  | -      confirm_button.classList.add("material-icons");
 | 
	
		
			
				|  |  | -      confirm_button.innerText = "send";
 | 
	
		
			
				|  |  | -      buttons.appendChild(confirm_button);
 | 
	
		
			
				|  |  |        cancel_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  |          this.hide();
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      confirm_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  | -        if (this.#action === false) {
 | 
	
		
			
				|  |  | -          return;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        this._action();
 | 
	
		
			
				|  |  | -        this.hide();
 | 
	
		
			
				|  |  | -      });
 | 
	
		
			
				|  |  | +      if (!this._info) {
 | 
	
		
			
				|  |  | +        const confirm_button = document.createElement("button");
 | 
	
		
			
				|  |  | +        confirm_button.classList.add("confirm");
 | 
	
		
			
				|  |  | +        confirm_button.classList.add("material-icons");
 | 
	
		
			
				|  |  | +        confirm_button.innerText = "send";
 | 
	
		
			
				|  |  | +        buttons.appendChild(confirm_button);
 | 
	
		
			
				|  |  | +        confirm_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  | +          if (this.#action === false) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          this._action();
 | 
	
		
			
				|  |  | +          this.hide();
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |        return container;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    };
 | 
	
	
		
			
				|  | @@ -669,6 +681,9 @@
 | 
	
		
			
				|  |  |      _get_input(name) {
 | 
	
		
			
				|  |  |        return this.get_query('input[name="' + name + '"]');
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    get _has_submit() {
 | 
	
		
			
				|  |  | +      return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      _build_node() {
 | 
	
		
			
				|  |  |        const center = document.createElement("div");
 | 
	
		
			
				|  |  |        center.classList.add("center");
 | 
	
	
		
			
				|  | @@ -698,12 +713,14 @@
 | 
	
		
			
				|  |  |        close_button.innerText = "close";
 | 
	
		
			
				|  |  |        close_button.type = "button";
 | 
	
		
			
				|  |  |        bottom.appendChild(close_button);
 | 
	
		
			
				|  |  | -      const send_button = document.createElement("button");
 | 
	
		
			
				|  |  | -      send_button.classList.add("send");
 | 
	
		
			
				|  |  | -      send_button.classList.add("material-icons");
 | 
	
		
			
				|  |  | -      send_button.innerText = "send";
 | 
	
		
			
				|  |  | -      send_button.type = "submit";
 | 
	
		
			
				|  |  | -      bottom.appendChild(send_button);
 | 
	
		
			
				|  |  | +      if (this._has_submit) {
 | 
	
		
			
				|  |  | +        const send_button = document.createElement("button");
 | 
	
		
			
				|  |  | +        send_button.classList.add("send");
 | 
	
		
			
				|  |  | +        send_button.classList.add("material-icons");
 | 
	
		
			
				|  |  | +        send_button.innerText = "send";
 | 
	
		
			
				|  |  | +        send_button.type = "submit";
 | 
	
		
			
				|  |  | +        bottom.appendChild(send_button);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |        close_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  |          this.hide();
 | 
	
		
			
				|  |  |        });
 | 
	
	
		
			
				|  | @@ -711,9 +728,15 @@
 | 
	
		
			
				|  |  |          target.preventDefault();
 | 
	
		
			
				|  |  |          this._process();
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      this._build_form();
 | 
	
		
			
				|  |  | +      this._refresh();
 | 
	
		
			
				|  |  |        return center;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    _refresh() {
 | 
	
		
			
				|  |  | +      while (this.#form.lastChild) {
 | 
	
		
			
				|  |  | +        this.#form.lastChild.remove();
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      this._build_form();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      _create_input(name, label_text, placeholder, worker = null) {
 | 
	
		
			
				|  |  |        const container = document.createElement("div");
 | 
	
		
			
				|  |  |        container.classList.add("input-container");
 | 
	
	
		
			
				|  | @@ -734,11 +757,14 @@
 | 
	
		
			
				|  |  |        if (!this.#form) {
 | 
	
		
			
				|  |  |          throw new Error("Screen is not visible yet!");
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -      this.#form.appendChild(container);
 | 
	
		
			
				|  |  | +      this._append_child(container);
 | 
	
		
			
				|  |  |        return () => {
 | 
	
		
			
				|  |  |          return input.value;
 | 
	
		
			
				|  |  |        };
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    _append_child(target) {
 | 
	
		
			
				|  |  | +      this.#form.appendChild(target);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      _clear_results() {
 | 
	
		
			
				|  |  |        if (!this.#result) {
 | 
	
		
			
				|  |  |          return;
 | 
	
	
		
			
				|  | @@ -1000,6 +1026,9 @@
 | 
	
		
			
				|  |  |      #target;
 | 
	
		
			
				|  |  |      #email;
 | 
	
		
			
				|  |  |      #phone;
 | 
	
		
			
				|  |  | +    get _email() {
 | 
	
		
			
				|  |  | +      return this.#email();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      get _phone() {
 | 
	
		
			
				|  |  |        return this.#phone();
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1022,21 +1051,167 @@
 | 
	
		
			
				|  |  |        this.#phone = this._create_input(
 | 
	
		
			
				|  |  |          "phone",
 | 
	
		
			
				|  |  |          "Phone number:",
 | 
	
		
			
				|  |  | -        "123-456-789",
 | 
	
		
			
				|  |  | +        "+1 123-456-789",
 | 
	
		
			
				|  |  |          (input) => {
 | 
	
		
			
				|  |  |            input.type = "tel";
 | 
	
		
			
				|  |  | -          input.pattern = "[0-9]{3}-[0-9]{3}-[0-9]{3}";
 | 
	
		
			
				|  |  | +          const add_prefix = () => {
 | 
	
		
			
				|  |  | +            if (input.value.length === 0) {
 | 
	
		
			
				|  |  | +              input.value = "+48 ";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          };
 | 
	
		
			
				|  |  | +          input.addEventListener("click", add_prefix);
 | 
	
		
			
				|  |  | +          input.addEventListener("focus", add_prefix);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        );
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  // application/scripts/reservation.js
 | 
	
		
			
				|  |  | +  var reservation = class _reservation {
 | 
	
		
			
				|  |  | +    email;
 | 
	
		
			
				|  |  | +    phone_number;
 | 
	
		
			
				|  |  | +    product_barcode;
 | 
	
		
			
				|  |  | +    constructor(target = null) {
 | 
	
		
			
				|  |  | +      this.email = null;
 | 
	
		
			
				|  |  | +      this.phone_number = null;
 | 
	
		
			
				|  |  | +      this.product_barcode = null;
 | 
	
		
			
				|  |  | +      if (target === null) {
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if ("email" in target) {
 | 
	
		
			
				|  |  | +        this.email = target["email"];
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if ("target_barcode" in target) {
 | 
	
		
			
				|  |  | +        this.product_barcode = target["target_barcode"];
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if ("phone_number" in target) {
 | 
	
		
			
				|  |  | +        this.phone_number = target["phone_number"];
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get dump() {
 | 
	
		
			
				|  |  | +      const dumped = {
 | 
	
		
			
				|  |  | +        "target_barcode": this.product_barcode
 | 
	
		
			
				|  |  | +      };
 | 
	
		
			
				|  |  | +      if (this.email !== null) {
 | 
	
		
			
				|  |  | +        dumped["email"] = this.email;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if (this.phone_number !== null) {
 | 
	
		
			
				|  |  | +        dumped["phone_number"] = this.phone_number;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      return dumped;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get ready() {
 | 
	
		
			
				|  |  | +      if (this.product_barcode === null) return false;
 | 
	
		
			
				|  |  | +      if (this.email === null && this.phone_number === null) return false;
 | 
	
		
			
				|  |  | +      return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    copy() {
 | 
	
		
			
				|  |  | +      return new _reservation(this.dump);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/product_rent_request.js
 | 
	
		
			
				|  |  | +  var product_rent_request = class extends request {
 | 
	
		
			
				|  |  | +    #reservation;
 | 
	
		
			
				|  |  | +    constructor(reservation2) {
 | 
	
		
			
				|  |  | +      super();
 | 
	
		
			
				|  |  | +      this.#reservation = reservation2;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get data() {
 | 
	
		
			
				|  |  | +      return Object.assign(this.#reservation.dump, {
 | 
	
		
			
				|  |  | +        "apikey": this._apikey
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _response() {
 | 
	
		
			
				|  |  | +      return bool_response;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get method() {
 | 
	
		
			
				|  |  | +      return "POST";
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get url() {
 | 
	
		
			
				|  |  | +      return "/rent/product/barcode/" + this.#reservation.product_barcode;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/reservation_factory.js
 | 
	
		
			
				|  |  | +  var reservation_factory = class {
 | 
	
		
			
				|  |  | +    #target;
 | 
	
		
			
				|  |  | +    constructor() {
 | 
	
		
			
				|  |  | +      this.#target = new reservation();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    phone_number(target) {
 | 
	
		
			
				|  |  | +      target = target.trim().replaceAll("-", "");
 | 
	
		
			
				|  |  | +      if (target.length === 0) {
 | 
	
		
			
				|  |  | +        target = null;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      this.#target.phone_number = target;
 | 
	
		
			
				|  |  | +      return this;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    email(target) {
 | 
	
		
			
				|  |  | +      target = target.trim();
 | 
	
		
			
				|  |  | +      if (target.length === 0) {
 | 
	
		
			
				|  |  | +        target = null;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      this.#target.email = target;
 | 
	
		
			
				|  |  | +      return this;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    product(target) {
 | 
	
		
			
				|  |  | +      this.#target.product_barcode = target.barcode;
 | 
	
		
			
				|  |  | +      return this;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    result() {
 | 
	
		
			
				|  |  | +      if (this.#target.ready) {
 | 
	
		
			
				|  |  | +        return this.#target;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      throw new Error("Target reservation is not ready yet.");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    // application/scripts/product_rent.js
 | 
	
		
			
				|  |  |    var product_rent = class extends rents_screen {
 | 
	
		
			
				|  |  |      get _name() {
 | 
	
		
			
				|  |  |        return "Product rent";
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    _process() {
 | 
	
		
			
				|  |  | +    async _process() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        this._info = "Processing...";
 | 
	
		
			
				|  |  | +        const target = new reservation_factory().email(this._email).phone_number(this._phone).product(this._target).result();
 | 
	
		
			
				|  |  | +        const request2 = new product_rent_request(target);
 | 
	
		
			
				|  |  | +        const response = await request2.connect();
 | 
	
		
			
				|  |  | +        if (!response.result) {
 | 
	
		
			
				|  |  | +          throw new Error(response.cause);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        this._success = "New rent added.";
 | 
	
		
			
				|  |  | +        searcher.reload();
 | 
	
		
			
				|  |  | +        setTimeout(() => {
 | 
	
		
			
				|  |  | +          this.hide();
 | 
	
		
			
				|  |  | +        }, 500);
 | 
	
		
			
				|  |  | +      } catch (error) {
 | 
	
		
			
				|  |  | +        this._error = String(error);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/product_give_back_request.js
 | 
	
		
			
				|  |  | +  var product_give_back_request = class extends request {
 | 
	
		
			
				|  |  | +    #reservation;
 | 
	
		
			
				|  |  | +    constructor(reservation2) {
 | 
	
		
			
				|  |  | +      super();
 | 
	
		
			
				|  |  | +      this.#reservation = reservation2;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get data() {
 | 
	
		
			
				|  |  | +      return Object.assign(this.#reservation.dump, {
 | 
	
		
			
				|  |  | +        "apikey": this._apikey
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _response() {
 | 
	
		
			
				|  |  | +      return bool_response;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get method() {
 | 
	
		
			
				|  |  | +      return "POST";
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get url() {
 | 
	
		
			
				|  |  | +      return "/give_back/product/barcode/" + this.#reservation.product_barcode;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1045,7 +1220,175 @@
 | 
	
		
			
				|  |  |      get _name() {
 | 
	
		
			
				|  |  |        return "Product give back";
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    async _process() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        this._info = "Processing...";
 | 
	
		
			
				|  |  | +        const target = new reservation_factory().email(this._email).phone_number(this._phone).product(this._target).result();
 | 
	
		
			
				|  |  | +        const request2 = new product_give_back_request(target);
 | 
	
		
			
				|  |  | +        const response = await request2.connect();
 | 
	
		
			
				|  |  | +        if (!response.result) {
 | 
	
		
			
				|  |  | +          throw new Error(response.cause);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        this._success = "Success!";
 | 
	
		
			
				|  |  | +        searcher.reload();
 | 
	
		
			
				|  |  | +        setTimeout(() => {
 | 
	
		
			
				|  |  | +          this.hide();
 | 
	
		
			
				|  |  | +        }, 500);
 | 
	
		
			
				|  |  | +      } catch (error) {
 | 
	
		
			
				|  |  | +        this._error = String(error);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/reservations_response.js
 | 
	
		
			
				|  |  | +  var reservations_response = class extends bool_response {
 | 
	
		
			
				|  |  | +    #collection;
 | 
	
		
			
				|  |  | +    constructor(target) {
 | 
	
		
			
				|  |  | +      super(target);
 | 
	
		
			
				|  |  | +      if (!this.result) {
 | 
	
		
			
				|  |  | +        return;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      this.#collection = new Array();
 | 
	
		
			
				|  |  | +      target["reservations"].forEach((count) => {
 | 
	
		
			
				|  |  | +        this.#collection.push(new reservation(count));
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get collection() {
 | 
	
		
			
				|  |  | +      if (!this.result) {
 | 
	
		
			
				|  |  | +        throw new Error(this.cause);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      return this.#collection;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/product_reservations_request.js
 | 
	
		
			
				|  |  | +  var product_reservations_request = class extends request {
 | 
	
		
			
				|  |  | +    #target;
 | 
	
		
			
				|  |  | +    constructor(target) {
 | 
	
		
			
				|  |  | +      super();
 | 
	
		
			
				|  |  | +      this.#target = target;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _response() {
 | 
	
		
			
				|  |  | +      return reservations_response;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get data() {
 | 
	
		
			
				|  |  | +      return {
 | 
	
		
			
				|  |  | +        "apikey": this._apikey
 | 
	
		
			
				|  |  | +      };
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get method() {
 | 
	
		
			
				|  |  | +      return "POST";
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get url() {
 | 
	
		
			
				|  |  | +      return "/reservations/product/barcode/" + this.#target.barcode;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/product_all_rents.js
 | 
	
		
			
				|  |  | +  var product_all_rents = class extends formscreen {
 | 
	
		
			
				|  |  | +    #target;
 | 
	
		
			
				|  |  | +    constructor(target) {
 | 
	
		
			
				|  |  | +      super();
 | 
	
		
			
				|  |  | +      this.#target = target;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _name() {
 | 
	
		
			
				|  |  | +      return "All rents";
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _has_submit() {
 | 
	
		
			
				|  |  | +      return false;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    #create_single(target) {
 | 
	
		
			
				|  |  | +      const container = document.createElement("div");
 | 
	
		
			
				|  |  | +      container.classList.add("reservation-info");
 | 
	
		
			
				|  |  | +      if (target.phone_number !== null) {
 | 
	
		
			
				|  |  | +        const phone_icon = document.createElement("span");
 | 
	
		
			
				|  |  | +        phone_icon.classList.add("material-icons");
 | 
	
		
			
				|  |  | +        phone_icon.innerText = "phone";
 | 
	
		
			
				|  |  | +        const phone_number = document.createElement("span");
 | 
	
		
			
				|  |  | +        phone_number.classList.add("numbers");
 | 
	
		
			
				|  |  | +        phone_number.innerText = target.phone_number;
 | 
	
		
			
				|  |  | +        const phone_number_container = document.createElement("p");
 | 
	
		
			
				|  |  | +        phone_number_container.appendChild(phone_icon);
 | 
	
		
			
				|  |  | +        phone_number_container.appendChild(phone_number);
 | 
	
		
			
				|  |  | +        container.appendChild(phone_number_container);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if (target.email !== null) {
 | 
	
		
			
				|  |  | +        const email_icon = document.createElement("span");
 | 
	
		
			
				|  |  | +        email_icon.classList.add("material-icons");
 | 
	
		
			
				|  |  | +        email_icon.innerText = "mail";
 | 
	
		
			
				|  |  | +        const email = document.createElement("span");
 | 
	
		
			
				|  |  | +        email.innerText = target.email;
 | 
	
		
			
				|  |  | +        const email_container = document.createElement("p");
 | 
	
		
			
				|  |  | +        email_container.appendChild(email_icon);
 | 
	
		
			
				|  |  | +        email_container.appendChild(email);
 | 
	
		
			
				|  |  | +        container.appendChild(email_container);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      return container;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    #create_single_button(target) {
 | 
	
		
			
				|  |  | +      const button = document.createElement("button");
 | 
	
		
			
				|  |  | +      button.classList.add("material-icons");
 | 
	
		
			
				|  |  | +      button.classList.add("give-back-button");
 | 
	
		
			
				|  |  | +      button.innerText = "save_alt";
 | 
	
		
			
				|  |  | +      button.addEventListener("click", async () => {
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +          this._info = "Processing...";
 | 
	
		
			
				|  |  | +          const request2 = new product_give_back_request(target);
 | 
	
		
			
				|  |  | +          const response = await request2.connect();
 | 
	
		
			
				|  |  | +          if (!response.result) {
 | 
	
		
			
				|  |  | +            throw new Error(response.cause);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          this._refresh();
 | 
	
		
			
				|  |  | +          searcher.reload();
 | 
	
		
			
				|  |  | +        } catch (error) {
 | 
	
		
			
				|  |  | +          this._error = String(error);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +      return button;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      _process() {
 | 
	
		
			
				|  |  | +      return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    async _build_form() {
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        this._info = "Loading...";
 | 
	
		
			
				|  |  | +        const request2 = new product_reservations_request(this.#target);
 | 
	
		
			
				|  |  | +        const response = await request2.connect();
 | 
	
		
			
				|  |  | +        const list = document.createElement("div");
 | 
	
		
			
				|  |  | +        list.classList.add("reservations-list");
 | 
	
		
			
				|  |  | +        let empty = true;
 | 
	
		
			
				|  |  | +        response.collection.forEach((count) => {
 | 
	
		
			
				|  |  | +          const item = document.createElement("div");
 | 
	
		
			
				|  |  | +          item.classList.add("reservation");
 | 
	
		
			
				|  |  | +          const left = this.#create_single(count);
 | 
	
		
			
				|  |  | +          const right = this.#create_single_button(count);
 | 
	
		
			
				|  |  | +          empty = false;
 | 
	
		
			
				|  |  | +          item.appendChild(left);
 | 
	
		
			
				|  |  | +          item.appendChild(right);
 | 
	
		
			
				|  |  | +          list.appendChild(item);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        this._append_child(list);
 | 
	
		
			
				|  |  | +        if (empty) {
 | 
	
		
			
				|  |  | +          this._success = "Not found any reservations.";
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +          this._clear_results();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      } catch (error) {
 | 
	
		
			
				|  |  | +        this._error = String(error);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // application/scripts/product_not_avairable.js
 | 
	
		
			
				|  |  | +  var product_not_avairable = class extends confirm_action {
 | 
	
		
			
				|  |  | +    get _title() {
 | 
	
		
			
				|  |  | +      return "Error";
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _description() {
 | 
	
		
			
				|  |  | +      return "This product is not avairable. Anybody can not rent it.";
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    get _info() {
 | 
	
		
			
				|  |  | +      return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1073,6 +1416,11 @@
 | 
	
		
			
				|  |  |      get #manage() {
 | 
	
		
			
				|  |  |        const manage = document.createElement("div");
 | 
	
		
			
				|  |  |        manage.classList.add("manage");
 | 
	
		
			
				|  |  | +      const all_rents_button = document.createElement("button");
 | 
	
		
			
				|  |  | +      all_rents_button.classList.add("material-icons");
 | 
	
		
			
				|  |  | +      all_rents_button.classList.add("all-rents-button");
 | 
	
		
			
				|  |  | +      all_rents_button.innerText = "list";
 | 
	
		
			
				|  |  | +      manage.appendChild(all_rents_button);
 | 
	
		
			
				|  |  |        const rent_button = document.createElement("button");
 | 
	
		
			
				|  |  |        rent_button.classList.add("material-icons");
 | 
	
		
			
				|  |  |        rent_button.classList.add("rent-button");
 | 
	
	
		
			
				|  | @@ -1093,8 +1441,15 @@
 | 
	
		
			
				|  |  |        delete_button.classList.add("delete-button");
 | 
	
		
			
				|  |  |        delete_button.innerText = "remove_circle_outline";
 | 
	
		
			
				|  |  |        manage.appendChild(delete_button);
 | 
	
		
			
				|  |  | +      all_rents_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  | +        new product_all_rents(this.#target).show();
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  |        rent_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  | -        new product_rent(this.#target).show();
 | 
	
		
			
				|  |  | +        if (this.#target.on_stock > 0) {
 | 
	
		
			
				|  |  | +          new product_rent(this.#target).show();
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +          new product_not_avairable().show();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |        give_back_button.addEventListener("click", () => {
 | 
	
		
			
				|  |  |          new product_give_back(this.#target).show();
 | 
	
	
		
			
				|  | @@ -1125,7 +1480,7 @@
 | 
	
		
			
				|  |  |        const stock_count = document.createElement("p");
 | 
	
		
			
				|  |  |        stock_count.classList.add("stock-count");
 | 
	
		
			
				|  |  |        stock_count.classList.add("material-icons");
 | 
	
		
			
				|  |  | -      if (this.#target.stock_count > 0) {
 | 
	
		
			
				|  |  | +      if (this.#target.on_stock > 0) {
 | 
	
		
			
				|  |  |          stock_count.innerText = "check_circle";
 | 
	
		
			
				|  |  |          stock_count.classList.add("avairable");
 | 
	
		
			
				|  |  |        } else {
 |