Jump to content

Availability Manager


fruid
 Share

Recommended Posts

OK so I was looking for a module for weekly schedules, available time slots and bookings thereof. But all I could find is other people looking for a module like that. So I gave it a try.

It's not a module yet but it will be soon, for now it merely is some templates and some fields. 

I gave ryan's ProcessHello module a try which makes module development much easier but I'm still not sure where to begin. How and where to create templates, with fields and repeater fields. Also, this setup requires FieldTypeTable which is a pro module so I'm not sure everyone will appreciate this requirement. I guess there could be an easier way? The tableish requirements are quite basic. 

https://foobar.roofaccess.org/userlogin/

if you have time and feel like it, you can just create a fake account and play around with it a bit, I hope it's somewhat self-explanatory.

Should the module do more? or less? I welcome any feedback! 

  • Like 1
Link to comment
Share on other sites

I actually have a very specific issue that I'm stuck with…

How do I make the module create the template files, not just the templates in the database via API but also the corresponding php files in the webcontent when being installed?

Link to comment
Share on other sites

I registered for check it, but confirmation mail didn't come.

I wrote a Fieldtype Module like this. I am using this private module for managing hotel rooms availabilities and room prices etc. I made 2 video for you, you can check the usage.

I used https://flatpickr.js.org/

 

Backend

Ekran Kaydı 2021-03-27 01.52.04.mov

Frontend

Ekran Kaydı 2021-03-27 01.58.10.mov

 

  • Like 3
Link to comment
Share on other sites

2 minutes ago, fruid said:

I actually have a very specific issue that I'm stuck with…

How do I make the module create the template files, not just the templates in the database via API but also the corresponding php files in the webcontent when being installed?

You can create your templates inside your modules folder, like "MyModule/templates/" on module installation you can copy these templates to "site/templates/" folder.

  • Like 1
Link to comment
Share on other sites

thanks @ukyo

11 minutes ago, ukyo said:

I registered for check it, but confirmation mail didn't come.

I guess it works now, you're clearly in the user list.

13 minutes ago, ukyo said:

thanks for the tipp, what's the name of the FieldType?

A sort of "range" input field that lets you drag with the mouse from start to end is cool for a month or year view but if you're trying to select multiple weeks over a a period of months, I reckon it's easier to just enter the week number and year. At least I couldn't find any time picker that makes this task easier, not in flatpickr nor anywhere, maybe something like drag or click the week number on a year calendar. 

And the other thing is entering times. The time input functionality from flatpickr is not much of use and dragging hardly could be an option since you would want to enter time slots and not so much ranges. So just having a simple text field is just as straight forward and probably more flexible. 

Link to comment
Share on other sites

I checked, Hotels, Booking, Airbnb admin panels all they have different solutions about managing availabilities, i created my own one like on video. You can find a solution for your self.

Link to comment
Share on other sites

11 hours ago, ukyo said:

You can create your templates inside your modules folder, like "MyModule/templates/" on module installation you can copy these templates to "site/templates/" folder.

and a follow up question:

if I do something like 

$src = $urls->site.'modules/myModule/templates/';
$dst = $urls->templates;
$move = wireCopy($src, $dst);

inside init() or ___execute()

It of course asks for what is $urls. How would I pass it the $urls variable because if I just put it in the brackets, it's too few arguments where it's called, which I don't know where.

Am I misunderstanding?

Link to comment
Share on other sites

public function ___install() {
	// do something when istall module
	$this->files->copy(__DIR__ '/templates/', $this->config->paths->templates);
}

You can add this operation inside install method. And don't use URL you need to use PATH.

Link to comment
Share on other sites

49 minutes ago, ukyo said:

$this->files->copy(__DIR__ '/templates/', $this->config->paths->templates);

ParseError
syntax error, unexpected ''/templates/'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' 

I don't get it

EDIT: I understand it needs to be

$this->files->copy(__DIR__.'/templates/', $this->config->paths->templates);

but still doesn't copy

Link to comment
Share on other sites

18 hours ago, fruid said:

I actually have a very specific issue that I'm stuck with…

How do I make the module create the template files, not just the templates in the database via API but also the corresponding php files in the webcontent when being installed?

This is something where PW is a little... special. The problem is that it decides wheter a page is viewable or not from the existance of /site/templates/yourtemplate. That means you don't have those files under control of your module. Copying the file on install is not ideal as well, because you end up getting a static copy that will not update on updates. You could of course copy your files also on every update, but that approach has 2 other problems: Development gets complicated because you need to copy back and forth your files while testing them. And second you might modify the template file in /site/templates because you (or someone else) thinks that this is the correct file and on the next update you lose your changes. Or you have the file under control of git and you get conflicts there...

To solve all that problems I have introduced the includeViews() method in RockMigrations: https://github.com/BernhardBaumrock/RockMigrations/blob/636cf1eca8f8f54683551ddea08ebc576c160124/RockMigrations.module.php#L305-L339

It will create a file in /site/templates/foo.php and you can happily code in /site/modules/YourModule/views/foo.php

<?php namespace ProcessWire;
// DONT CHANGE THIS FILE
// it is created automatically via RockMigrations
include($config->paths->root.'site/modules/YourModule/views/foo.php');

 

  • Like 1
Link to comment
Share on other sites

On 3/27/2021 at 1:20 AM, ukyo said:

You can take FieldtypeEvents as reference for you.

FieldTypeEvents is a separate fieldtype module. I understand it's just an example of how to create custom fields. I'm not sure though how that would fit in here – would I create that custom field that I need inside the module itself? Or would it also be a separate module that my custom module requires/installs? It actually seems quite basic in its functionality and comes quite close to what I need, but the code looks quite complex to be honest.

Link to comment
Share on other sites

apologies for the misconduct here in the forums, this happens when I don't start a new thread right away but actually start with researching existing posts to begin with, which I like to think to always do thouroughly.

@Jan Romero as a matter of fact I do have ProFields Table and it is dope indeed, but like I mentioned in this thread here, I (and maybe others) would prefer the module I'm building and its dependencies to be free of charge, considering the still quite basic requirements it has to the tableish nature of the inputfield. 

I also use Tracy Debugger, but I'm not always sure how to use it though. 

I agree a table field is far more complex than say a checkbox field, yet it's still what is used to explain how to build a custom field, i.e. FieldTypeEvents, and my requirements not much different either, so I thought I give it a shot. Besides, I learn a lot more by doing than with too much theory. But maybe this is more long term project after all.

Thanks so far everybody.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...