{"id":1852,"date":"2021-03-19T21:14:31","date_gmt":"2021-03-19T20:14:31","guid":{"rendered":"https:\/\/fhumanes.es\/blog\/?p=1852"},"modified":"2021-03-19T21:27:06","modified_gmt":"2021-03-19T20:27:06","slug":"nuevo-plugin-bootstrap-datapicker","status":"publish","type":"post","link":"https:\/\/fhumanes.es\/blog\/nuevo-plugin-bootstrap-datapicker\/","title":{"rendered":"Nuevo plugin \u00abBootstrap Datapicker\u00bb"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-1142\" src=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2020\/05\/plugin_phprunner-300x181.png\" alt=\"\" width=\"150\" height=\"91\" srcset=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2020\/05\/plugin_phprunner-300x181.png 300w, https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2020\/05\/plugin_phprunner.png 397w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/>Este nuevo plugin es un selector de fecha.<\/p>\n<p>El selector de fecha de PHPRunner tiene muchas posibilidades\u00a0 y es muy f\u00e1cil de configurar, pero&#8230;&#8230; le falta la gesti\u00f3n de <strong>d\u00edas festivos<\/strong> (no seleccionables) y esto es principalmente lo que aporta este plugin.<\/p>\n<p>Est\u00e1 disponible <a href=\"https:\/\/fhumanes.es\/blog\/guias-desarrollo\/plugines-de-phprunner\/\">en la p\u00e1gina de plugines.<\/a><\/p>\n<p><!--more--><\/p>\n<p>En la demo se ha configurado con:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/\/ The days of the week are: 0 (Sunday) to 6 (Saturday)\r\n$this-&gt;settings[\"required\"] = false; \/\/ Wether is mandatory\r\n$this-&gt;settings[\"tooltip\"] = 'Enter the date of ......'; \/\/ Tooltip of field\r\n$this-&gt;settings[\"format\"] = 'mm\/dd\/yyyy'; \/\/ Format of presentation of the date\r\n$this-&gt;settings[\"weekStart\"] = '0'; \/\/ Day in which the week begins\r\n$this-&gt;settings[\"startDate\"] = '02\/01\/2021'; \/\/ Selectable initil date. The defined date format must be used\r\n$this-&gt;settings[\"endDate\"] = '05\/31\/2021'; \/\/ Selectable end date. The defined date format must be used\r\n$this-&gt;settings[\"todayBtn\"] = true; \/\/ So that \"today\" button appears\r\n$this-&gt;settings[\"clearBtn\"] = true; \/\/ So that \"clean\" button appears\r\n$this-&gt;settings[\"daysOfWeekDisabled\"] = \"0,6\"; \/\/ Days of the week I do not work\r\n$this-&gt;settings[\"daysOfWeekHighlighted\"] = \"0,6\"; \/\/ Days of the week highlighted \r\n$this-&gt;settings[\"calendarWeeks\"] = true ; \/\/ If in the calendar you show the information number\r\n$this-&gt;settings[\"autoclose\"] = true ; \/\/ If when selecting a date, the calendar window is closed\r\n$this-&gt;settings[\"todayHighlight\"] = true ; \/\/ If the current day is highlighted\r\n$this-&gt;settings[\"language\"] = 'en-GB' ; \/\/ Calendar language. Consult URL: https:\/\/github.com\/uxsolutions\/bootstrap-datepicker\/tree\/master\/dist\/locales\r\n$this-&gt;settings[\"datesDisabled\"] = array('03\/03\/2021', '03\/24\/2021','04\/07\/2021','04\/21\/2021'); \/\/ Holidays Array of days is defined according to the format that has been specified.<\/pre>\n<p>Por defecto, el campo de base de datos es de tipo \u00abvarchar\u00bb. Para poner de tipo \u00abdate\u00bb o \u00abdatetime\u00bb, debemos programar los siguientes eventos:<\/p>\n<p><strong>Before record updates | added<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$format = 'm\/d\/Y';\r\nif ( $values['datePicker'] &lt;&gt;'') {\r\n    $date_a = DateTime::createFromFormat($format,$values['datePicker']);\r\n    $values['datePicker'] = $date_a-&gt;format('Y-m-d');\r\n} else {\r\n    $values['datePicker'] = NULL;\r\n}\r\nreturn true;<\/pre>\n<p>En \u00abEDIT pages\u00bb en el evento<strong> Process record values<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$format = 'm\/d\/Y';\r\nif ( $values['datePicker'] &lt;&gt; NULL ) {\r\n    $values['datePicker'] = date($format, strtotime($values['datePicker']));\r\n} else {\r\n    $values['datePicker'] = '';\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Este nuevo plugin es un selector de fecha. El selector de fecha de PHPRunner tiene muchas posibilidades\u00a0 y es muy f\u00e1cil de configurar, pero&#8230;&#8230; le falta la gesti\u00f3n de d\u00edas festivos (no seleccionables) y esto es principalmente lo que aporta este plugin. Est\u00e1 disponible en la p\u00e1gina de plugines.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-1852","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts\/1852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/comments?post=1852"}],"version-history":[{"count":3,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts\/1852\/revisions"}],"predecessor-version":[{"id":1855,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts\/1852\/revisions\/1855"}],"wp:attachment":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/media?parent=1852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/categories?post=1852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/tags?post=1852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}