public static function getJquery()
    {
        ob_start();
        ?>
		<script>
			$(document).ready(function(){
				$('#<?php 
        echo TS_Module_HRM_PresencePlanning_Tables_EmployeeLeavesTable::TABLE_BODY_CSS_ID;
        ?>
')
					.on('change', '.<?php 
        echo self::$field_value_input_class;
        ?>
', function(e) {
					// cache this element, and reset any background-color
					e.stopPropagation();
					var $this = $(this);
					$this.css({ "background-color" : "#FFA500", "border-color" : "#FFA500" });
					 
					// get new value
					var new_value = $this.val();
					if ($this.attr('type') == 'checkbox') { new_value = ($this.is(':checked') ? 1 : 0); }
					if ($this.attr('type') == 'number' && new_value.length == 0) { new_value = 0; }
					
					// send value to be stored
					$.ajax({
						cache	: false,
						type	: "POST",
						dataType: "text",
						url		: "<?php 
        echo TS_Module_HRM_PresencePlanning_Links::getHref('set_employee_leave_field_value');
        ?>
",
						data	: {
							record_id	: $this.attr('data-recordid'),
							field_value	: new_value,
							field_name	: $this.attr('data-fieldname')
						}
					}).done(function( data ) {
						$this.css({ "background-color" : ( data == 1 ? "#D4FFA9" : "#FF6464" ), "border-color" : ( data == 1 ? "#D4FFA9" : "#FF6464" ) });
					}).fail(function( ) {
						$this.css({ "background-color" : "#FF6464", "border-color" : "#FF6464" });
					});
				});
			});
		</script>
		<?php 
        return ob_get_clean();
    }
示例#2
0
 private static function addTab($page_name, $icon_name, $add_record_info = false)
 {
     $tmp_page_title_ar[] = self::$module_pages_ar[$page_name];
     if ($add_record_info) {
         $tmp_page_title_ar[] = self::$employee->getName();
     }
     $page_title = implode(' | ', $tmp_page_title_ar);
     $page_link = HTML::A(TS_Module_Icons::get($icon_name, 1.5, $page_title) . $page_title);
     // Check if provided page is the currently selected page
     if (self::$selected_page == $page_name) {
         $page_link->class = 'selected_tab';
         self::$current_page_subtitle_ar[] = $page_title;
     }
     // add any extra url parameters
     $url_extra_params_ar = array();
     if ($add_record_info) {
         $url_extra_params_ar['employee_id'] = self::$employee->id;
     }
     $page_link->href = TS_Module_HRM_PresencePlanning_Links::getHref($page_name, $url_extra_params_ar);
     $page_link->title = $page_title;
     self::$tabs_links_ar[] = $page_link;
 }
 private static function getRemoveEmployeeLeaveLink($leave_id)
 {
     // create local filter
     $filter_ar = self::$filter_ar;
     // set leave_id and action
     $filter_ar['leave_id'] = $leave_id;
     $filter_ar['action'] = 'remove_leave';
     // set go_to_page_name
     $go_to_page_name = !empty($filter_ar['page']) ? $filter_ar['page'] : 'edit_employee';
     unset($filter_ar['page']);
     // build and return link
     $link = HTML::A(TS_Module_Icons::get('delete_item'), '', 'link_img');
     $link->title = 'Verwijder verlof ID ' . $leave_id . ' van : ' . self::$employee->name;
     $link->href = TS_Module_HRM_PresencePlanning_Links::getHref($go_to_page_name, $filter_ar);
     return $link;
 }
    private static function getJquery()
    {
        // get column id's to center
        $centerable_column_id_ar = self::getFilteredHeaderIDsByClass('center');
        $unsortable_column_id_ar = self::getFilteredHeaderIDsByClass('unsortable');
        ob_start();
        ?>
		<!-- DataTables -->
		<script type="text/javascript" charset="utf8" src="<?php 
        echo External_JQuery_DataTables_CDN::getJavaScriptUrl();
        ?>
"></script>

		<script>
			// DataTables CSS from CDN
			var tmp_DataTablesStyle = document.createElement("link");
			tmp_DataTablesStyle.rel = "stylesheet";
			tmp_DataTablesStyle.href = "<?php 
        echo External_JQuery_DataTables_CDN::getCssUrl();
        ?>
";
			document.getElementsByTagName("head")[0].appendChild(tmp_DataTablesStyle);

			$(document).ready(function(){
				var planning_datatable = $('#<?php 
        echo self::TABLE_ID;
        ?>
').DataTable({
					"ajax"			: "<?php 
        echo TS_Module_HRM_PresencePlanning_Links::getHref('get_json_planning', self::$filter_ar);
        ?>
",
					"language"		: { "url": "/js/new/datatables/dutch.json" },
					"order"			: [[ 1, "asc" ]],
					//"lengthMenu"	: [[25, 50, 100, -1], [25, 50, 100, "Alle"]],
					"lengthMenu"	: [[-1, 100, 50, 25], ["Alle", 100, 50, 25]],
					"columnDefs"	: [
						{ "orderable": false, "targets": [ <?php 
        echo implode(', ', $unsortable_column_id_ar);
        ?>
 ] },
						{
							"targets": [ <?php 
        echo implode(', ', $centerable_column_id_ar);
        ?>
 ],
							"createdCell": function (td, cellData, rowData, row, col) {
								$(td).css('text-align', 'center');
							}
						}
					]
				});
			});
		</script>
		<?php 
        return ob_get_clean();
    }
    public static function getJquery()
    {
        ob_start();
        ?>
		<script>
			$(document).ready(function(){
				$('body').on('change', '.<?php 
        echo self::FIELD_VALUE_INPUT_CLASS;
        ?>
', function(e) {
					// cache this element, and reset any background-color
					e.stopPropagation();
					var $this = $(this);
					var $parent = $this.closest('td');
					
					// (re)set parent css background style
					$parent.removeClass('bg_green');
					$parent.removeClass('bg_red');
					$parent.removeClass('bg_orange');
					$parent.addClass('bg_orange');
					$parent.find(".glyphicon").remove();
					 
					// set variables
					var this_input_type	= $this.attr('type');
					var new_value		= $this.val();
					
					// send value to be stored
					$.ajax({
						cache	: false,
						type	: "POST",
						dataType: "text",
						url		: "<?php 
        echo TS_Module_HRM_PresencePlanning_Links::getHref('ajax_set_employee_presence_value');
        ?>
",
						data	: {
							employee_id		: $this.attr('data-employeeid'),
							presence_date	: $this.attr('data-presencedate'),
							field_value		: new_value
						}
					}).done(function( data ) {
						$parent.removeClass('bg_orange');
						if (data == 1) {
							$this.before('<?php 
        echo Bootstrap::Icon('ok', false);
        ?>
');
						} else {
							$this.before('<?php 
        echo Bootstrap::Icon('remove', false);
        ?>
');
						}
						$parent.addClass((data == 1 ? 'bg_green' : 'bg_red'));
					}).fail(function( ) {
						$this.before('<?php 
        echo Bootstrap::Icon('remove', false);
        ?>
');
						$parent.removeClass('bg_orange');
						$parent.addClass('bg_red');
					});
				});
			});
		</script>
		<?php 
        return ob_get_clean();
    }