Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: [FIXED] add fullcalendar in my component

add fullcalendar in my component 11 Oct 2017 09:38 #15360

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
Romkabouter wrote:
Can you tell me why you can not show the fullcalendar in your component? I don't really understand that part.
Is it on another website or something?

Hello
actually I have the calendar in my component.
I do not know if I did it correctly but here is my component folder.

in my site part :
I created a folder "Calendar" with all the javascript file I need for the calendar :

then I put in the CSS folder all the css of the calendar

the calendar is call via a <div id="calendar"></ div>
then there is a script of configuration for the calendar that I put directly in my view demandes.php before the calendar div like :
<?php
/**                               ______________________________________________
*                          o O   |                                              |
*                 (((((  o      <    Generated with Cook Self Service  V3.1.9   |
*                ( o o )         |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version		
* @package		Litssupp
* @subpackage	Demandes
* @copyright	
* @author		 -  - 
* @license		
*
*             .oooO  Oooo.
*             (   )  (   )
* -------------\ (----) /----------------------------------------------------------- +
*               \_)  (_/
*/

// no direct access
defined('_JEXEC') or die('Restricted access');


LitsuppHelper::headerDeclarations();
//Load the formvalidator scripts requirements.
JDom::_('html.toolbar');

?>

<?php
// Render the page title
echo JLayoutHelper::render('title', array(
	'params' => $this->params,
	'title' => null,
	'browserTitle' => null
)); ?>
	<script>
	
	$(function() { // document ready

		$('#calendar').fullCalendar({
		
			eventRender: function(event, element) {
				$(element).popover({
					title: function () {
						return "<B>" + event.title + "</B>";
					},
					placement:'right',
					html:true,
					trigger : 'hover',
					animation : 'false',
					content: function () {
						return "<h1> " + event.title + "</h1>"
					},
					container:'body'
				}).popover('show');
			},	

				now: '2017-09-07',
				editable: true,
				aspectRatio: 1.8,
				scrollTime: '00:00',
				header: {
					left: 'today prev,next',
					center: 'title',
					right: 'timelineMonth,timelineYear'
				},
				defaultView: 'timelineMonth',
				views: {
					timelinDay: {
						buttonText: ':15 slots',
						slotDuration: '00:15'
					},
					timelineTenDay: {
						type: 'timeline',
						duration: { days: 10 }
					}
				},
				navLinks: true,
				resourceAreaWidth: '25%',
				resourceLabelText: 'Rooms',
			resourceColumns: [
				{
					group: true,
					labelText: 'Type de Lit',
					field: 'building'
				},
				{
					labelText: 'Lit',
					field: 'title'
				},
			],
			
			resources: { // you can also specify a plain string like 'json/resources.json'
					url: 'localhost/index.php?option=com_litsupp&view=lits'
				},
			
			events: { // you can also specify a plain string like 'json/events.json'
					url: 'localhost/index.php?option=com_litsupp&view=demandes'
				}
			
		});
	});

	</script>
<form action="<?php echo(JRoute::_("index.php")); ?>" method="post" name="adminForm" id="adminForm">
	<div class="row-fluid">
		<div id="contents" class="span12">

			<!-- BRICK : toolbar_plur -->
			<?php echo $this->renderToolbar($this->items);?>

			<!-- BRICK : search -->
			<?php echo $this->filters['search_search']->input;?>

			<!-- BRICK : display -->
			<div class="pull-right">
				<?php echo $this->filters['sortTable']->input;?>
			</div>


			<div class="pull-right">
				<?php echo $this->filters['directionTable']->input;?>
			</div>


			<div class="pull-right">
				<?php echo $this->filters['limit']->input;?>
			</div>


			<!-- BRICK : filters -->
			<div class="pull-left">
				<?php echo $this->filters['filter_start']->input;?>
			</div>


			<div class="pull-left">
				<?php echo $this->filters['filter_end']->input;?>
			</div>


			<div class="clearfix"></div>

			<!-- BRICK : grid -->
			<?php echo $this->loadTemplate('grid'); ?>
			
			<!-- CLENDAR -->
			<div id='calendar'></div>
			
			<!-- BRICK : pagination -->
			<?php echo $this->pagination->getListFooter(); ?>

		</div>
	</div>


	<?php 
		$jinput = JFactory::getApplication()->input;
		echo JDom::_('html.form.footer', array(
		'values' => array(
					'view' => $jinput->get('view', 'demandes'),
					'layout' => $jinput->get('layout', 'demandes'),
					'boxchecked' => '0',
					'filter_order' => $this->escape($this->state->get('list.ordering')),
					'filter_order_Dir' => $this->escape($this->state->get('list.direction'))
				)));
	?>
</form>

in the default layout 'lits" and "demandes" there are my json outputs for "ressources" and "event" call
Last Edit: 11 Oct 2017 10:10 by Nicolas.
The administrator has disabled public write access.

add fullcalendar in my component 11 Oct 2017 10:44 #15361

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Allright, looks ok but you do not need the url

First, do (can be just below JDom::_('html.toolbar'); or so)
//build json for demandes
$json_demandes = array();
$demandes = LitsuppHelper::getData('demandes',array(
));
for ($i=0; $i < count( $demandes ); $i++):
	$row = $demandes[$i];
	$obj = new stdClass;
	$obj->id = $row->id;
	$obj->Chambre = $row->Chambre;
	$obj->_Chambre_numero = $row->_Chambre_numero;
	$obj->start = $row->start;
	$obj->end = $row->end;
	$obj->events = $row->events;
	$obj->nom_client = $row->nom_client;
	$obj->resourceId = $row->resourceId;
	$obj->title = $row->title;
	//assign to the json_demandes array
	$json_demandes[] = $obj;
endfor;

//build json for lits

$json_lits = array();
$lits = LitsuppHelper::getData('lits',array(
));
for ($i=0; $i < count( $lits ); $i++):
	$row = $lits[$i];
	$obj = new stdClass;
	//See demandes, for every needed field to this
	$obj->id = $row->id;
	//....more field....
	//
	//assign to the json_lits array
	$json_lits[] = $obj;
endfor;

Then you have two json variables, check what is returned in the data in $demandes en $lits.
If you want to know more about orm, check this page: www.j-cook.pro/index.php/o/orm-system

Then, instead of
			resources: { // you can also specify a plain string like 'json/resources.json'
					url: 'localhost/index.php?option=com_litsupp&view=lits'
				},
			
			events: { // you can also specify a plain string like 'json/events.json'
					url: 'localhost/index.php?option=com_litsupp&view=demandes'
				}
do
<?php
echo "resources: ".json_encode($json_lits ) . "," . "events: "" . json_encode($json_demandes);
?>

I might have made some typos, but you get the general idea :)

The whole for loop stuff might even not be needed, but let's not go that way (yet ;) )
Last Edit: 11 Oct 2017 10:45 by Romkabouter.
The administrator has disabled public write access.
The following user(s) said Thank You: Nicolas

add fullcalendar in my component 11 Oct 2017 21:54 #15367

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
oh wow thank you.
ORM system is all what i need.

Thank you so much for your help.

I have never been as jumped on joomla since I registered on jcook.

again thank you for everything to you two friends.

you can close the topic
The administrator has disabled public write access.

add fullcalendar in my component 12 Oct 2017 08:22 #15370

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Here is a little topic I wrote how to maintain your forked code:

www.j-cook.pro/index.php/support/9-codin...g-your-project#13101
The administrator has disabled public write access.
The following user(s) said Thank You: admin, Nicolas

add fullcalendar in my component 14 Oct 2017 04:52 #15371

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
Romkabouter wrote:
Here is a little topic I wrote how to maintain your forked code:

www.j-cook.pro/index.php/support/9-codin...g-your-project#13101

Excelent Topic. i will don't forget

just one last question on the foreign entries.
You call the room number like :
$obj->chambre = $row->_Chambre_numero;

but it return "null".
can you explain me how can i search my room number to add it in my Json output ?
The administrator has disabled public write access.

add fullcalendar in my component 14 Oct 2017 06:52 #15372

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Try debugging the properties with var_dump($row); somewhere in the for-loop.

In ORM, the default naming convention for a foreign key = _<foreignmodel>_<field>. So in your case that should be _chambre_numero.
Maybe the context is not as expected, you can have more control over what the getData function returns when you use "context" => "layout.whatever"
The context is state bound, so the model can hold a different layout then what you need. A layout is a set of fields, typically the same as the views you have created in the builder.

Read all about it here: www.j-cook.pro/index.php/o/orm-system
The administrator has disabled public write access.
The following user(s) said Thank You: Nicolas

add fullcalendar in my component 14 Oct 2017 10:30 #15373

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
I just tried and I get
object(stdClass)[431]
  public 'id' => string '1' (length=1)
  public 'title' => string '123456' (length=6)
  public 'nom_client' => string 'Master' (length=6)
  public 'start' => string '2017-09-01' (length=10)
  public 'end' => string '2017-09-04' (length=10)
  public 'resourceId' => string '1' (length=1)
  public 'Chambre' => string '1' (length=1)
  public 'remarques' => null
  public 'params' => 
    object(JObject)[435]
      protected '_errors' => 
        array (size=0)
          empty
      public 'access-view' => boolean true
I do not have my variable for the Room number << Chambre_numero>> :
$json_demandes = array();
$demandes = LitsuppHelper::getData('demandes',array(
));
for ($i=0; $i < count( $demandes ); $i++):
	$row = $demandes[$i];
	$obj = new stdClass;
	$obj->id = $row->id;
	$obj->Chambre = $row->Chambre;
	$obj->_Chambre_numero = $row->_Chambre_numero;
	$obj->start = $row->start;
	$obj->end = $row->end;
	$obj->nom_client = $row->nom_client;
	$obj->resourceId = $row->resourceId;
	$obj->title = $row->title;
	//assign to the json_demandes array
	$json_demandes[] = $obj;
endfor;

Where can i find any tutorial on default naming convention
Last Edit: 14 Oct 2017 10:32 by Nicolas.
The administrator has disabled public write access.

add fullcalendar in my component 16 Oct 2017 11:08 #15375

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
In your first post you had _Chambre_numero, did you change a layout in the builder? (Removed the field numero?)
Nicolas wrote:
HI everyone !
I have done what you have proposed.
So I added the request file to the fork folder and made the call like this
		<?php
		for ($i=0, $n=count( $this->items ); $i < $n; $i++):
			$row = $this->items[$i];
			echo json_encode($row);
		endfor;
		?>

it gives me this result
{"id":"1","Chambre":"1","_Chambre_numero":"135","end":"2017-09-05","events":null,"nom_client":"Master","resourceId":"1","_resourceId_title":"Lit parapluie 1","start":"2017-09-02","title":"123456","params":{"access-view":true,"access-edit":true,"access-delete":true}}

can you explain to me how to remove everything that is in red please?
Last Edit: 16 Oct 2017 11:09 by Romkabouter.
The administrator has disabled public write access.
The following user(s) said Thank You: Nicolas

add fullcalendar in my component 16 Oct 2017 21:30 #15380

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
It works when I write
//build json for demandes
$json_demandes = array();
for ($i=0; $i < count( $this->items ); $i++):
	$row = $this->items[$i];
	$obj = new stdClass;
	$obj->id = $row->id;
	$obj->Chambre = $row->Chambre;
	$obj->Chambre_numero = $row->_Chambre_numero;
	$obj->start = $row->start;
	$obj->end = $row->end;
	$obj->nom_client = $row->nom_client;
	$obj->resourceId = $row->resourceId;
	$obj->title = $row->title;
	//assign to the json_demandes array
	$json_demandes[] = $obj;
endfor;

By cons when I need on the same page to have sort of bed with this
//build json for lits
$json_lits = array();
$lits = LitsuppHelper::getData('lits',array(
));
for ($i=0; $i < count( $lits ); $i++):
	$row = $lits[$i];
	$obj = new stdClass;
	//See demandes, for every needed field to this
	$obj->id = $row->id;
	$obj->building = $row->_building_nom;
	$obj->title = $row->title;
	$obj->eventColor = $row->eventColor;
	//assign to the json_lits array
	$json_lits[] = $obj;
endfor;
I still have the foreign key problem on _building_nom
but I can no longer use <this->items> that returns me the <demandes table>

Unfortunately I need both so I do not know how to call the table <lits> with the foreign key _building_name
The administrator has disabled public write access.

add fullcalendar in my component 17 Oct 2017 08:47 #15386

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
With ORM, you namespace the fields for creating relations
$this->orm(array(
    'select' => 'Chambre.numero'
));

And then the values are stored in a simple list (not a tree), so as said Romkabouter you use '_' respecting the convention : _[fk_field]_[field]
echo $row->_Chambre_numero;
Coding is now a piece of cake
The administrator has disabled public write access.

add fullcalendar in my component 17 Oct 2017 08:53 #15387

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
And for N:m, you call it with 'relation'

For instance when 'Chambre' (Room) contains one or many 'Lits' (Beds), you can list all 'Lits' from 'Chambre'
$modelChambre->orm(array(
    'relation' => array(
        'lits' => array(
             'select' => array('longueur', 'largeur')
        )
    )
));

The relation (lits), must have been defined in the model constructor. (Cook does prepare all relations)
The result will give you a list of items inside the 'lits' field.
foreach($row->lits as $lit)
{
    echo $lit->largeur;
    echo $lit->longueur;
}
Coding is now a piece of cake
Last Edit: 17 Oct 2017 08:55 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: Nicolas

add fullcalendar in my component 17 Oct 2017 08:59 #15388

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Ok, maybe you should need some more help on ORM ;)

The base call is
$lits = LitsuppHelper::getData('lits',array(
));
But that will probably not be what you want, you can have more finegrained control of the data you want.
Use "select" to get the fields you need
$lits = LitsuppHelper::getData('lits',array(
  'select' => array(
          'title'
        , 'eventColor'
    )
));
You can rename fields as well:
$lits = LitsuppHelper::getData('lits',array(
  'select' => array(
          'title' => 'othername'
        , 'eventColor'
    )
));

So, now you want a field in a foreign key table, just add the namespace of the FK and the field:
$lits = LitsuppHelper::getData('lits',array(
  'select' => array(
          'title'
        , 'eventColor'
        ,'building.nom'
    )
));

You can also do all sorts of filters on the data, please read the orm documentation, it's quite good in this area:
www.j-cook.pro/index.php/o/orm-system
The administrator has disabled public write access.
The following user(s) said Thank You: Nicolas

add fullcalendar in my component 17 Oct 2017 09:55 #15390

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
admin wrote:
With ORM, you namespace the fields for creating relations
$this->orm(array(
    'select' => 'Chambre.numero'
));
echo $row->_Chambre_numero;

return "null"
Ok, maybe you should need some more help on ORM ;)
Ok it's great, I'm starting to understand. I thought that with a basic call I found all with the model "lits"
$lits = LitsuppHelper::getData('lits',array(
));
but the basic call only calls the table and not the foreign keys. I must therefore ask him to take them also with
$lits = LitsuppHelper::getData('lits',array(
  'select' => array(
          'title'
        , 'eventColor'
        ,'building.nom'
    )
));
Thank you for everything. This time everything works fine.
building_nom returns well "lit parapluie"

I learn for pleasure and at the same time tries to create some tools for my work and this training me.

This site is awesome and I hope that new tutorials will come.
how did you find these tips Romkabouter ?
The administrator has disabled public write access.

add fullcalendar in my component 17 Oct 2017 10:21 #15394

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Trail and error and docs :D

I have got some components which are heavily forked and then you come across all sorts of stuff you need.
I have spent countless hours figuring out how to achieve what I needed. Programming is my job, but in different languages.
Reverse engineering stuff to see why something does not work how I expected it to work leads to discovering features and sometimes finding defects.

I am thinking about creating a topic to showcase some components by the way, just need to take some time for that ;)
The administrator has disabled public write access.

add fullcalendar in my component 17 Oct 2017 20:54 #15396

  • Nicolas
  • Nicolas's Avatar
  • Offline
  • Premium Member
  • Posts: 82
  • Thank you received: 12
  • Karma: 6
Romkabouter wrote:
Trail and error and docs :D

I have got some components which are heavily forked and then you come across all sorts of stuff you need.
I have spent countless hours figuring out how to achieve what I needed. Programming is my job, but in different languages.
Reverse engineering stuff to see why something does not work how I expected it to work leads to discovering features and sometimes finding defects.

I am thinking about creating a topic to showcase some components by the way, just need to take some time for that ;)

I am like you and I like to understand how things work. That's why I started coding.
I would read your document with pleasure when you have time for it.

I think we can close the topic to avoid cluttering the forum.

Thanks again for everything !

ps : i bookmark your profil to show your future topic
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.138 seconds

Get Started